There are a lot of problems with this script.
Loops
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()
table.sort(lights, function(a, b) return tonumber(a.Name:sub(2)) < tonumber(b.Name:sub(2) end)
for i = 1, 9 do
for j = 1, #lights do
lights[j].PointLight.Enabled = false
end
for j = i, #lights, 10 do
lights[j].PointLight.Enabled = true
end
wait(0.03)
end
Positions
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?
1 comment
Thanks so much for the help. It has been a very, very long time since I have done anything with Lua, let alone the rbx extension of it.I believe I was wanting to remove the repeat and keep the while, but I'm not completely sure... It's amazing what jetlag and a little bit of insomnia will do to your brain. :D Thanks for the help!