I'm working on a script that change your team and open a Gui when you die, but it only work onetime.
Here is my script, I put it into ServerScriptSevice
:
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local gui = player.PlayerGui:FindFirstChild("TeamGUI"):WaitForChild("Background")
player.TeamColor = game.Teams:findFirstChild("Choosing").TeamColor
wait(3)
gui.Visible = true
end)
end)
end)
I don't know why but only the Teamcolor works several times and the Gui once.
it's because your event works only when player joins
your script works like: Player joined AND died then gui appears
you need to do:
Player Joined OR Dies
like this in LocalScript
local plr = game:GetService('Players').LocalPlayer
plr.CharacterAdded:Connect(function() -- when character loads (Player Joins or Die) your gui should appear
local gui = player.PlayerGui:FindFirstChild("TeamGUI"):WaitForChild("Background")
plr.TeamColor = game.Teams:findFirstChild("Choosing").TeamColor
wait(3)
gui.Visible = true
end)
try this, if its not work then comment