I want a player to be teleported away from a part if their team color doesn't match the part's color. Output says there is a problem with line 4, can anyone help me?
1 | script.Parent.Touched:connect( function (hit) |
2 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
3 | wait() |
4 | if player.TeamColor = = BrickColor.new( "Bright blue" ) or player.TeamColor = = BrickColor.new( "Really blue" ) and script.Parent.BrickColor = = BrickColor.new( "Bright green" ) then |
5 | hit.Parent.Torso.CFrame = CFrame.new(Vector 3. new(- 49 , 4 , 109 )) |
6 | elseif player.TeamColor = = BrickColor.new( "Bright green" ) or player.TeamColor = = BrickColor.new( "Camo" ) and script.Parent.BrickColor = = BrickColor.new( "Bright blue" ) then |
7 | hit.Parent.Torso.CFrame = CFrame.new(Vector 3. new(- 49 , 4 ,- 79 )) |
8 | end |
9 | end ) |
Try making "local player = " to "local player = game.Players.LocalPlayer" , add a wait(2) at line 1 and make it a local script
1 | script.Parent.Touched:connect( function (hit) |
2 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
3 | wait() |
4 | if player.TeamColor.BrickColor = = BrickColor.new( "Bright blue" ) or player.TeamColor.BrickColor = = BrickColor.new( "Really blue" ) and script.Parent.BrickColor = = BrickColor.new( "Bright green" ) then |
5 | hit.Parent.Torso.CFrame = CFrame.new(Vector 3. new(- 49 , 4 , 109 )) |
6 | elseif player.TeamColor.BrickColor = = BrickColor.new( "Bright green" ) or player.TeamColor.BrickColor = = BrickColor.new( "Camo" ) and script.Parent.BrickColor = = BrickColor.new( "Bright blue" ) then |
7 | hit.Parent.Torso.CFrame = CFrame.new(Vector 3. new(- 49 , 4 ,- 79 )) |
8 | end |
9 | end ) |