Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

0
You need remote events and learn server to client stuff. mixgingengerina10 223 — 5y
0
Pretty sure it's not working because if statements run only once. User#19524 175 — 5y
0
then put a loop lol greatneil80 2647 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
His whole point was for when the team changed. Not when he respawned. chexburger 358 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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..

0
Eww GetChildren don't do that. And PlayerGui should NOT be accessed by the server. Use a remote event. User#19524 175 — 5y
0
Uhhhhh WillBe_Stoped 71 — 5y
0
incapaz, playergui can be accessed by server, but it only can use guis generated by server, and not startergui maumaumaumaumaumau 98 — 5y
0
Doesn't work too. :/ WillBe_Stoped 71 — 5y
View all comments (3 more)
0
wait server script or local script? WillBe_Stoped 71 — 5y
0
localscript greatneil80 2647 — 5y
0
The only reason this won't work is because you are probably using it incorrectly greatneil80 2647 — 5y
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

0
Sadly, does not work :( WillBe_Stoped 71 — 5y
0
true* not True greatneil80 2647 — 5y
0
Sorry, I typed from Phone AswormeDorijan111 531 — 5y
0
Try now AswormeDorijan111 531 — 5y

Answer this question