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

Can someone help me fix this script?

I am having trouble with a index error with this script, please see if you can fix it:

C1 = BrickColor.new(script.Parent:FindFirstChild("Body Colors").TorsoColor)
C2 = C1.Color

wait(1)

while true do
wait()
script.Parent:FindFirstChild("Body Colors").HeadColor = Color3.new(C2)
script.Parent:FindFirstChild("Body Colors").LeftArmColor = Color3.new(C2)
script.Parent:FindFirstChild("Body Colors").LeftLegColor = Color3.new(C2)
script.Parent:FindFirstChild("Body Colors").RightArmColor = Color3.new(C2)
script.Parent:FindFirstChild("Body Colors").RightLegColor = Color3.new(C2)
wait(1/4)
script.Parent.Torso.Smoke.Color = Color3.new(C2)
script.Parent.Torso.PointLight.Color = Color3.new(C2)
wait(1/4)
script.Parent.Head.Transparency = 0.5
script.Parent:FindFirstChild("Left Arm").Transparency = 0.5
script.Parent:FindFirstChild("Left Leg").Transparency = 0.5
script.Parent:FindFirstChild("Right Arm").Transparency = 0.5
script.Parent:FindFirstChild("Right Leg").Transparency = 0.5
script.Parent.Torso.Transparency = 0.5
end

Basically I want to change character stuff, and I already have a script to put it in the persons character.

1 answer

✓ Accepted answer

It looks good except for C2 is already a Color3 value, so you don't need to have Color3.new(C2) you just need C2.

C1 = BrickColor.new(script.Parent:FindFirstChild("Body Colors").TorsoColor)
C2 = C1.Color

-- Variables are your friend
local bc = script.Parent:FindFirstChild("Body Colors")
local torso = script.Parent:FindFirstChild("Torso")
local head = script.Parent:FindFirstChild("Head")
local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
local lleg = script.Parent:FindFirstChild("Left Leg")
local rleg = script.Parent:FindFirstChild("Right Leg")

wait(1)

while true do -- remember to indent scopes for clean looking code :)
	wait()
	bc.HeadColor = C2
	bc.LeftArmColor = C2
	bc.LeftLegColor = C2
	bc.RightArmColor = C2
	bc.RightLegColor = C2
	wait(1/4)
	torso.Smoke.Color = C2
	torso.PointLight.Color = C2
	wait(1/4)
	head.Transparency = 0.5
	larm.Transparency = 0.5
	lleg.Transparency = 0.5
	rarm.Transparency = 0.5
	rleg.Transparency = 0.5
	torso.Transparency = 0.5
end

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