How exactly would I be able to detect if a player is on a team. This GUI opens another GUI, but I only want it to do the stuff in the script if the player is on one of ***two *** select teams.
local black = false function codrop() if black == false then script.Parent:TweenPosition(UDim2.new(0, 0,0, 350), "In", "Linear", 2) wait(0.1) black = true script.Parent.Parent.CourtMenu.Text = "Close CM" elseif black == true then script.Parent:TweenPosition(UDim2.new(0, 1500,0, 350), "Out", "Linear", 1) black = false script.Parent.Parent.CourtMenu.Text = "Court Menu (CJ)" end end script.Parent.Parent.CourtMenu.MouseButton1Down:connect(codrop)
edit: or... maybe the GUI button you click on to open this item would only be visible to two teams, rather than it just not doing anything
There is a Property in the Player called TeamColor
.
There is also a Property in the Team object called TeamColor
If you compare these two proeperties, to check if they're equivelant, as a prerequisite to any further code.. then it will only allow the specified TeamColor use the button.
local black = false local plr = game.Players.LocalPlayer --The Player local team = game.Teams.Blue --The Team You Want function codrop() if not black then script.Parent:TweenPosition(UDim2.new(0, 0,0, 350), "In", "Linear", 2) wait(0.1) black = true script.Parent.Parent.CourtMenu.Text = "Close CM" else script.Parent:TweenPosition(UDim2.new(0, 1500,0, 350), "Out", "Linear", 1) black = false script.Parent.Parent.CourtMenu.Text = "Court Menu (CJ)" end end script.Parent.Parent.CourtMenu.MouseButton1Down:connect(function() if plr.TeamColor == team.TeamColor then --Check if they match codrop() --Call the function end end)
NOTE: This should be a LocalScript in order for it to work.
Use a local script to run this code. On line 4 on the if loop change the color BrickColor.new("White") to the color of the team you want to access the gui. Then put the code to open the gui inside the if loop. It will check if the player is on the right team when the function is called and then if the player is on the team then it will open the gui, if the player is not on the team it will exit the function and therefore ignore the open gui code.
player = game.Players.LocalPlayer function codrop() if player.TeamColor == BrickColor.new("White") then --gui code end end script.Parent.Parent.CourtMenu.MouseButton1Down:connect(codrop)