Jump to content

[HELP] If player in team, outputChatBox


Recommended Posts

Hello, I am trying to make a job script, and I want to make a function where, if the player is not in the Criminal job then the gui will appear, else outputChatBox a message, here is the code:

addEventHandler ( "onClientMarkerHit" , Marker , 
function ( hitPlayer ) 
    if not (getPlayerTeam(hitPlayer) == "Criminal") then 
        guiSetVisible ( GUIEditor.window[1] , true ) 
        showCursor ( true )  
        outputChatBox("You are already a criminal!", hitPlayer, 255, 0, 0) 
end , false ) 

It doesn't output the message nor the gui.

Link to comment

Returns a team element and "Criminal" is a string, so you can't compare them that way. You have to convert the string into a team or the team into a string, I would recommend the first option to avoid errors in case a player doesn't have a team at all.

if getPlayerTeam(hitPlayer) == getTeamFromName("Criminal") then 

And that's all you need.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...