Hello, I have problem with my script. I'd like to create script that hides GUI after player changes on a specific team. Script I had:
local Player = game.Players.LocalPlayer local TB = game.StarterGui.ScreenGui.Frame TB.Visible = false if game.Player.TeamColor == BrickColor.new('Really red') then TB.Visible = true end
Actually worked but It worked only after joining game. But I want to make it execute every time after player changes team.
Script that should work:
local function onTeamColorChanged() local TB = game.StarterGui.ScreenGui.Frame TB.Visible = false if game.Player.TeamColor == BrickColor.new('Really red') then TB.Visible = true end end Player:GetPropertyChangedSignal("TeamColor"):Connect(onTeamColorChanged)
I want anyone here help me with it.
game.Player is not how you index the variable, do Player
local Player = game.Players.LocalPlayer local TB = Player:WaitForChild("PlayerGui").ScreenGui.Frame -- PlayerGui is what the client see, StarterGui is what server see, so use PlayerGui!! TB.Visible = false local function onTeamColorChanged() -- local TB = game.StarterGui.ScreenGui.Frame You already made it TB.Visible = false if Player.TeamColor == BrickColor.new('Really red') then TB.Visible = true end end onTeamColorChanged() Player:GetPropertyChangedSignal("TeamColor"):Connect(onTeamColorChanged)