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

How to change this line of script into local?

So I have this line of script and I have to change it to local but I don't know how to.

function onSkinChanged()
	if skin.Value == 1 then brickcolor = 125 end -- this is the part where it says it should be changed
	if skin.Value == 2 then brickcolor = 18 end
	if skin.Value == 3 then brickcolor = 217 end
	if skin.Value == 4 then brickcolor = 192 end
	player.Character:findFirstChild("Left Arm").BrickColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Right Arm").BrickColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Left Leg").BrickColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Right Leg").BrickColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Torso").BrickColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Body Colors").LeftArmColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Body Colors").RightArmColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Body Colors").LeftLegColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Body Colors").RightLegColor = BrickColor.new(brickcolor)
	player.Character:findFirstChild("Body Colors").TorsoColor = BrickColor.new(brickcolor)
	player.Character.NewHead.Handle.BrickColor = BrickColor.new(brickcolor)
	UpdateSliders()
end

1 answer

✓ Accepted answer

Just add local brickcolor = 0 to the start of the function.

How your script will look like:

function onSkinChanged()
	local brickcolor = 0 -- Here we put the local.
    if skin.Value == 1 then brickcolor = 125 end -- this is the part where it says it should be changed
    if skin.Value == 2 then brickcolor = 18 end
    if skin.Value == 3 then brickcolor = 217 end
    if skin.Value == 4 then brickcolor = 192 end
    player.Character:findFirstChild("Left Arm").BrickColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Right Arm").BrickColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Left Leg").BrickColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Right Leg").BrickColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Torso").BrickColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Body Colors").LeftArmColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Body Colors").RightArmColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Body Colors").LeftLegColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Body Colors").RightLegColor = BrickColor.new(brickcolor)
    player.Character:findFirstChild("Body Colors").TorsoColor = BrickColor.new(brickcolor)
    player.Character.NewHead.Handle.BrickColor = BrickColor.new(brickcolor)
    UpdateSliders()
end

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