I have this script here that changes you to the orange team once you die. It works but I want to disable it for a few seconds at the beginning of each game. When I add a wait though it permanently disables the script.
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) c:WaitForChild("Humanoid").Died:connect(function() p.TeamColor = BrickColor.new("Bright orange") --Or what ever team color it is. end) end) end)
Thanks
It would probably be easiest to not use an anonymous function (at least for the PlayerAdded event), then just wait a certain time before connecting the function to the event. So,
function changeTeam(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() player.TeamColor = BrickColor.new("Bright orange") end) end) end wait(50) game.Players.PlayerAdded:connect(changeTeam)
However, once this is connected, it will stay connected. If you want to be able to stop this script from working whenever you want, you use the disconnect()
method.
function changeTeam(player) CA = player.CharacterAdded:connect(function(character) D = character:WaitForChild("Humanoid").Died:connect(function() player.TeamColor = BrickColor.new("Bright orange") end) end) end wait(50) PA = game.Players.PlayerAdded:connect(changeTeam) --stuff CA:disconnect() D:disconnect() --Disconnects the events. PA:disconnect()