Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it so that a player in a certain team can have this textbutton visible?

So I basically want to make it so that if a player is on a certain team (In this instance the team is called "Staff") then This Text Button should be visible for them.

if game.Players.LocalPlayer.Team.Name == "Staff" then
	local player = game.Players.LocalPlayer
	player:WaitForChild("PlayerGui").ScreenGui.Spawn.Disable.Visible = true
end

I have no idea if this works under filtering enabled but when I tried "Play Solo" in studio it didn't work either Add me on discord if you don't get the question 3ptWRLD#8788

3 comments

0

You need remote events and learn server to client stuff.

0

Pretty sure it's not working because if statements run only once.

0

then put a loop lol

3 answers

✓ Accepted answer

LocalScript

game.Players.LocalPlayer:GetPropertyChangedSignal("TeamColor"):Connect(function()
	if game.Players.LocalPlayer.TeamColor = BrickColor.new("TEAMCOLOR") then
		game.Players.LocalPlayer.GUI.FRAME.Visible = true -- Set to make your gui visible.
	end
end)

Edit: Above script won't work. Use below instead

Server Script

game.Players.PlayerAdded:Connect(function(player)
	player.Changed:Connect(function(property)
		if property == "TeamColor" then
			if player.TeamColor == BrickColor.new("COLOR") then
				
			end
		end
	end)
end)

1 comment

0

His whole point was for when the team changed. Not when he respawned.

Try this:

Make sure the script is not in startergui but instead, server storage

while wait() do
for _, v in pairs(game.Players:GetChildren()) do
  if v:FindFirstChild("Staff") then
      v.PlayerGui.ScreenGui.Spawn.Disable.Visible = true
  end  
end
end

Oh and by the way, sometimes your code glitches if you have properties as variables..

7 comments

0

Eww GetChildren don't do that. And PlayerGui should NOT be accessed by the server. Use a remote event.

0

Uhhhhh

0

incapaz, playergui can be accessed by server, but it only can use guis generated by server, and not startergui

0

Doesn't work too. :/

0

wait server script or local script?

0

localscript

0

The only reason this won't work is because you are probably using it incorrectly

You can try this LOCAL script. Make sure to put it inside StarterGui.

local Player = game.Player.LocalPlayer

TeamName = "Staff"

game.Players.PlayerAdded:Connect(function()
if Player.Team.Name == TeamName then
local GUI = Player.PlayerGui:WaitForChild("ScreenGui")
GUI.Spawn.Disable.Visible = true
end
end)

Hope that this works

4 comments

0

Sadly, does not work :(

0

true* not True

0

Sorry, I typed from Phone

0

Try now

This discussion is preserved as it was. New answers, comments, and votes are closed.