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
01 | player = game.Players.LocalPlayer |
02 | playerName = "" ..player.name |
03 | Character = game.Workspace:WaitForChild(playerName) |
04 | --[[Tables]] |
05 | local BrickColor = { BrickColor.new( "White" ), BrickColor.new( "Black" ), BrickColor.new( "Medium stone grey" ) } |
06 |
07 | function Respawn() |
08 | Lives = player.NoSave:WaitForChild( "Lives" ) |
09 | Playing = player.NoSave:WaitForChild( "Playing" ) |
10 | if player.TeamColor ~ = BrickColor [ 3 ] then |
11 | if Lives > 0 then |
12 | Lives = Lives - 1 |
13 | elseif Lives = = 0 then |
14 | player.TeamColor = BrickColor [ 3 ] |
15 | end |
Thanks
You added a little extra ()
And you put character instead of Character. I also removed playerName because it wasn't needed. For example:
01 | player = game.Players.LocalPlayer |
02 | Character = game.Workspace:WaitForChild(player.Name) |
03 | --[[Tables]] |
04 | local BrickColor = { BrickColor.new( "White" ), BrickColor.new( "Black" ), BrickColor.new( "Medium stone grey" ) } |
05 |
06 | function Respawn() |
07 | Lives = player.NoSave:WaitForChild( "Lives" ) |
08 | Playing = player.NoSave:WaitForChild( "Playing" ) |
09 | if player.TeamColor ~ = BrickColor [ 3 ] then |
10 | if Lives > 0 then |
11 | Lives = Lives - 1 |
12 | elseif Lives = = 0 then |
13 | player.TeamColor = BrickColor [ 3 ] |
14 | end |
15 | elseif player.TeamColor = = BrickColor [ 3 ] then return end |
16 | end |
17 |
18 | Character:WaitForChild( "Humanoid" ).Died:connect(Respawn) |