When press play to test my script I get an error on line 6. Not sure what's wrong :/
torso = game.StarterPlayer.StarterCharacter.Torso playercolor = math.random(1,5) if playercolor == 1 then torso.BrickColor = Color3.fromRGB(242, 243, 243) end elseif playercolor == 2 then torso.BrickColor = Color3.fromRGB(196, 40, 28) end elseif playercolor == 3 then torso.BrickColor = Color3.fromRGB(40, 127, 71) end elseif playercolor == 4 then torso.BrickColor = Color3.fromRGB(27, 42, 53) end else torso.BrickColor = Color3.fromRGB(99, 95, 98) end
You only need one end for a set of if/elseif/else conditionals. elseif acts as the end for the if on line 3.
Per the comment: Yes, just wrap it in a function within the player.CharacterAdded event like so:
game.Players.PlayerAdded:Connect(function(p) p.CharacterAdded:Connect(function (c) torso = c.Torso playercolor = math.random(1,5) if playercolor == 1 then torso.BrickColor = Color3.fromRGB(242, 243, 243) elseif playercolor == 2 then torso.BrickColor = Color3.fromRGB(196, 40, 28) elseif playercolor == 3 then torso.BrickColor = Color3.fromRGB(40, 127, 71) elseif playercolor == 4 then torso.BrickColor = Color3.fromRGB(27, 42, 53) else torso.BrickColor = Color3.fromRGB(99, 95, 98) end end) end)