Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

This script works in studio but not play? What's wrong with my script anyway?

Asked by 9 years ago
game.Players.PlayerAdded:connect(function(player)
        while not player.Character do wait() end
    local Ch=player.Character
        Ch["Torso"].BrickColor=BrickColor.Black()
    Ch["Head"].BrickColor=BrickColor.Red()
    Ch["Head"].face.Texture = 'http://www.roblox.com/asset/?id=135269441'
    Ch["Left Arm"].BrickColor=BrickColor.Black()
    Ch["Right Arm"].BrickColor=BrickColor.Black()
    Ch["Left Leg"].BrickColor=BrickColor.Black()
    Ch["Right Leg"].BrickColor=BrickColor.Black()
end)


-- WHAT'S WRONG WITH IT?!

1 answer

Log in to vote
1
Answered by
Mokiros 135
9 years ago

After PlayerAdded event, you can use CharacterAdded event to find loaded character.

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(character)
        character:WaitForChild("Torso").BrickColor=BrickColor.Black()
        character:WaitForChild("Head").BrickColor=BrickColor.Red()
        character:WaitForChild("Head").face.Texture = 'http://www.roblox.com/asset/?id=135269441'
        character:WaitForChild("Left Arm").BrickColor=BrickColor.Black()
        character:WaitForChild("Right Arm").BrickColor=BrickColor.Black()
        character:WaitForChild("Left Leg").BrickColor=BrickColor.Black()
        character:WaitForChild("Right Leg").BrickColor=BrickColor.Black()
        --[[    I used :WaitForChild() to give character time to load]]
    end)
end)

Also, you can change BodyColors:

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(character)
        character:WaitForChild("Body Colors")
        character["Body Colors"].TorsoColor = BrickColor.Black()
        character["Body Colors"].HeadColor = BrickColor.Black()
        character:WaitForChild("Head")
        character.Head:WaitForChild("face").Texture = 'http://www.roblox.com/asset/?id=135269441'
        character["Body Colors"].LeftArmColor = BrickColor.Black()
        character["Body Colors"].RightArmColor = BrickColor.Black()
        character["Body Colors"].LeftLegColor = BrickColor.Black()
        character["Body Colors"].RightLegColor = BrickColor.Black()
end)
end)

P.S. You can press F9 in online mode to go to developer console, and search for script errors.

0
Thanks because I'm scirping a werewolf and it's aggravating. And tbh this is still not working! When I go to Test Server Mode in studio? It works, when I go to Play mode from the website? IT DOESNT WORK!! james24dj 90 — 9y
Ad

Answer this question