Other than the fact that this isn't in a function(I'm not very good with those outside of JS, Python & C++), and that it is probably way longer than it probably needs to be, what is the issue? I have fifty red lights set up outside of an exploding rocket and I want the lights to go around in a chasing pattern when the rocket is on the ground.
P.S. - Most of the script is just reiterating script.Parent.Lights.lx.PointLight.Enabled = T/F
in order starting at l1, l11, l21, l31, l41 as true, then l2, l12, l22, l32, l42 as true and so on and so forth until l10, l20, l30, l40 ,l50.
Pastebin Link for the script - http://pastebin.com/RrWDQZp2
There are a lot of problems with this script.
This script is ridiculous. You should have stopped yourself before you got here and asked, "Is there a better way?" because the answer is a resounding yes.
Use a loop.
local lights = script.Parent.Lights:GetChildren() -- You could use `script.Parent.Lights["l" .. i]` instead of sorting, but this is cleaner table.sort(lights, function(a, b) return tonumber(a.Name:sub(2)) < tonumber(b.Name:sub(2) end) -- (You could also sort by `x` or something similar) for i = 1, 9 do -- Start by turning them all off for j = 1, #lights do lights[j].PointLight.Enabled = false end -- Turn every 10 on, starting with the `i`th one -- (1, 11, 21, ...) -- (2, 12, 22, ...) -- ... -- (i, i+10, i+20, ...) -- ... -- (9, 19, 29, ...) for j = i, #lights, 10 do lights[j].PointLight.Enabled = true end wait(0.03) end
Positions aren't functions. x(y)
is only used for functions.
Positions are Vector3s. To make new Vector3s, we use the Vector3.new(x, y, z)
constructor function.
while workspace.Rocket.Engine.Position == Vector3.new(300.004, -252.007, 62.4) and workspace.Rocket.Engine2.Position == Vector3.new(310.2, -252.007, 62.4) and ....
Comparing positions is a bad idea. If the thing moves at all, even trillionths of a stud, the comparison will fail. If the object is not anchored, this is all but guaranteed. If the object is anchored, there is very little chance of returning it precisely to this spot if it ever leaves.
You should probably consider a different way to determine if it's done.
Also note that it's really strange to use both the repeat
and while
. What were you trying to accomplish?