Deleted post, confidential

Deleted post,

Confidential, that is not given out public any longer.

1 Like

What’s your original script? It’d make it easier to simplify knowing the relevant code

1 Like

Looking at the two animated GIFs, I can say that you need to do some sorting of the objects. - I suspect you have implicitly done the sorting in your ~294 lines script.

Because this line here in particular, where a table is returned from lights:GetChildren(), you have no idea in what order or sequence the elements are in, when querying them from the workspace:

for i,v in pairs(lights:GetChildren()) do

So I would suggest you first sort the “lights”, to truly ensure they are in a determinable sequence within the table.

local lightsArray = lights:GetChildren()
-- Reorder the lights, after their X position in the world
-- (or other _determinable_ position-value of the light-object)
table.sort(
  lightsArray,
  function(a,b)
    return a.Position.X < b.Position.X
  end
)

When you have a sorted table of those light objects, you could then use the table-item’s index as the ‘offset’:

while script.Parent ~= nil do
  local firstAngle = tick() -- Keep this value immutable in the for-loop.
  for index, lightObject in ipairs(lightsArray) do
    local offset = (index - 1) / #lightsArray
    local angle = firstAngle + offset
    local pan  = math.sin(angle)
    local tilt = math.cos(angle)
    -- ...
  end
  wait()
end
1 Like

Deleted post,

Confidential, that is not given out public any longer.

Deleted post,

Confidential, that is not given out public any longer.

1 Like

You could pretty easily simplify the script down to like two loops

Doing something along the lines of:

for i,v in pairs(game.Workspace.TaLights:GetChildren()) do
    local num = tonumber(v.Name:match("Ta(%d+)"))
    if num then
        local phase = 1 + .3 * (num-1)
        v.Motors.Tilt.MaxVelocity = (velocity)
        v.Motors.Pan.MaxVelocity = (velocity)
        v.Motors.Tilt.DesiredAngle = math.sin(x +phase) + 10 / 5
        v.Motors.Pan.DesiredAngle = math.cos(x + phase)
    end
end

This isn’t the full code of course but I trust you can put it together
It also isn’t the most efficient system but whatever reply if there are problems with it (there probably are)

1 Like

My bad! I forgot to put the lines of the code that is used to power the speed (the slider in this case).

Everything works as expected. Thank you.

You can just do

--do this above where phase is defined or something
local sign = num > 12 and -1 or 1

--random code in between
blahblahblah = sign * math.cos(x + phase)
1 Like

Deleted post,

Confidential, that is not given out public any longer.

Try using a multiple of 2π/23 instead of 0.3
2π/23 itself is pretty close to 0.3, so I would just use:

local phase = num * 2 * math.pi / 23

Also try doing this:

math.sin(x + half * phase)
math.cos(x + half * phase)

And edit this line to be non negative just like this:

v.Motors.Pan.DesiredAngle = half * math.cos(x + phase)

In a simulation of the angles where the Y axis is the tilt and the X axis is the pan:
image
(The circles are spread out along the x axis so you can see them)
It looks symmetric

1 Like

Deleted post,

Confidential, that is not given out public any longer.

Wait how are the lights organized? I was under the impression that they were organized in pairs like this:

1 Like

The lower ones go as you marked within the screenshot.
Although the lower ones are the different way, It starts with Ta1 on the left all the way to Ta24
The upper ones start from Ta24 on the left to Ta1 on the right.

I have it like that to look at both ways if the Beams are standing or hanging, to look at how the effects such as Lamp or Movement (math.rad/sin/cos) would look.

I could remove the upper ones for now, to focus on the main thing (Lower ones) more.

Oh wait I didnt realize you left off the half on cos

v.Motors.Pan.DesiredAngle = half * math.cos(x + half * phase)

Sorry I didnt specify I just wanted you to remove the - sign, but keep the half at the beginning as well as adding on the half inside of it

1 Like

That one makes it much better, I don’t know about this one though:
https://gyazo.com/318ca50cc21a3baafc3d2dbc8ecfd082

For some reason the Ta12 and Ta13 look off.

Do you mean that they are going faster than the rest?

1 Like

They are going the same speed, it’s the middle part which looks off centered.
Ta12 goes down first and then Ta13, when both are supposed to do it at the same time.
Pay attention to the left beam within the middle (Ta12) which goes down first.
https://gyazo.com/7e0959f4cdbe5e924aef3e9d8b8d5c56

Top view of the Beams:
https://gyazo.com/8aaec92a8bf50802881cf26cb4cf841b

Try printing the actual desired angle of Ta12 and Ta13 each time the main while loop runs and comparing if theyre very close but opposite
It might be an issue of motor6ds being slow or something

1 Like

It might be the math.pi problem, I am not sure.

Pan should have the same number, the -0.9 and 0.9 are fine until you see the rest of the numbers on both of them.
Same goes for Tilt, except all the numbers are different.
The numbers shown in the screenshot are the starting position before it starts to move, since the speed was on 0.