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

Script that changes an NPC Skincolor doesnt manage to work properly, why?

Can anyone help me understanding why does the script only run once? It was mean to repeat every 0.1 seconds but it doesnt... I have already tried remaking the script but it didnt work.

--Skin
while wait (0.1) do
	
if game.Players.LocalPlayer.Clothes.SkinColor.Value == 0 then
game.Workspace.Camera.NPCS.Character.Head.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LeftFoot.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LeftHand.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LeftLowerArm.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LeftLowerLeg.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LeftUpperArm.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LeftUpperLeg.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.LowerTorso.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.RightFoot.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.RightHand.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.RightLowerArm.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.RightLowerLeg.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.RightUpperArm.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.RightUpperLeg.BrickColor = BrickColor.new("Pastel brown")
game.Workspace.Camera.NPCS.Character.Parent.UpperTorso.BrickColor = BrickColor.new("Pastel brown")
end

end

2 comments

0

You should just iterate through parts instead of doing it seperately

0

You should use BodyColors instead of changing every body part individually

1 answer

✓ Accepted answer

The reason it doesn't work like you expected it , is because > Start | | Boolean expression -- true do the block of code | | false | | end

wait isn't a Boolean expression so it wouldn't do it how ya want it to do rather do this:

if game.Players.LocalPlayer.Clothes.SkinColor.Value == 0 then
for i,v in pairs(game.Workspace.Camera.NPCS.Character:GetChildren())
v:IsA("Part")
v.BrickColor = BrickColor.new("Pastel brown")
end
end

This will iterate over all the parts in the NPCS body and turn tell pastel brown. You wouldn't need a while true do loop because colour is a (kinda) 2 value property so it is either true or not meaning you don't need to to do it multiple times .

Or do this

game.Workspace.Camera.NPCS.Character.BodyColors = all the parts of the model

If it has that look at http://wiki.roblox.com/index.php?title=API:Class/BodyColors .

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