Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

1 comment

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!!

This discussion is preserved as it was. New answers, comments, and votes are closed.