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

Why can I not run this light chaser animation?

I have a script that is supposed to make a bunch of cylinder parts change their material, enable their lights, and then reset their material and turn those lights off, one light at a time, 24 times.

But, when I run my script, I get Workspace.Big Bass Wheel.BobberAssembly.LightChaserScript:5: attempt to call a number value

Here is my script:

--Light Chasing Animation
--by Yellowboy111
lightFolder = script.Parent.Lights
while true do
	for i in 1, 24 do
		lightFolder[tostring(i)].Material = Enum.Material.Neon
		lightFolder[tostring(i)].PointLight.Enabled = true
		wait(0.1)
		lightFolder[tostring(i)].Material = Enum.Material.Plastic
		lightFolder[tostring(i)].PointLight.Enabled = false
		wait(0.1)
	end
	wait(0.1)
end

1 comment

0

Never mind, in line 5 I had for i in 1, 24 do, but in reality I needed the line to say for i = 1, 24 do, my bad.

1 answer

your for loop is wrong, this how it works

local loops = 24 
for i = 1, loops do
-- The code
end

this means the for loop will loop 24 time from 1 to 24

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