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

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

Asked by 7 years ago

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
0
You should just iterate through parts instead of doing it seperately farrizbb 465 — 7y
0
You should use BodyColors instead of changing every body part individually Mayk728 855 — 7y

1 answer

Log in to vote
0
Answered by
farrizbb 465 Moderation Voter
7 years ago
Edited 7 years ago

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 .

Ad

Answer this question