I want to call this function upon the died event, you're on the Grey team if you're in the lobby. This is a local script in the StarterGUI
player = game.Players.LocalPlayer playerName = ""..player.name Character = game.Workspace:WaitForChild(playerName) --[[Tables]] local BrickColor = {BrickColor.new("White"), BrickColor.new("Black"), BrickColor.new("Medium stone grey")} function Respawn() Lives = player.NoSave:WaitForChild("Lives") Playing = player.NoSave:WaitForChild("Playing") if player.TeamColor ~= BrickColor[3] then if Lives > 0 then Lives = Lives - 1 elseif Lives == 0 then player.TeamColor = BrickColor[3] end elseif player.TeamColor == BrickColor[3] then return end end --[[I don't know how to do this last bit (calling) This is what it normally is: character:WaitForChild("Humanoid").Died:connect(function() Would I do:]] character:WaitForChild("Humanoid").Died:connect(Respawn()
Thanks
You added a little extra ()
And you put character instead of Character. I also removed playerName because it wasn't needed. For example:
player = game.Players.LocalPlayer Character = game.Workspace:WaitForChild(player.Name) --[[Tables]] local BrickColor = {BrickColor.new("White"), BrickColor.new("Black"), BrickColor.new("Medium stone grey")} function Respawn() Lives = player.NoSave:WaitForChild("Lives") Playing = player.NoSave:WaitForChild("Playing") if player.TeamColor ~= BrickColor[3] then if Lives > 0 then Lives = Lives - 1 elseif Lives == 0 then player.TeamColor = BrickColor[3] end elseif player.TeamColor == BrickColor[3] then return end end Character:WaitForChild("Humanoid").Died:connect(Respawn)