Problems with alarm panel

A script with this code is inserted in each alarm part

while true do
script.Parent.Transparency = 0.25
script.Parent.Decal.Transparency = 0
task.wait(0.2)
script.Parent.Transparency = 1
script.Parent.Decal.Transparency = 1
if script.Stop.Value then
script:Destroy()
end
task.wait(0.2)
end

In this video, you can see half of the alarms randomly sync. The point of the alarms is when one actuates they blink independently of each other, and this is what happens in the beginning until something makes half of them start to sync, then they SLOWLY start to go out of sync again. Im trying to solve the syncing problem

this is the trigger code

for _,v in pairs(workspace[“2K10”].Alarms:GetChildren()) do
local FastBlink = script.FastBlink:Clone()
FastBlink.Enabled = true
FastBlink.Parent = v
wait(math.random(1,500)/1000)
end

First of all, I would strongly suggest you to use CollectionService for applying same functionality for multiple similar parts.

So the sync problem arrives because task.wait() is tied to Roblox’s global task scheduler
because of that they can easily line up on same frame. To fix that you could use Roblox’s RunService to implement delays ourselves. So the solution would look something like this:

local RunService = game:GetService("RunService")

local blinkSpeed = 0.4 -- total cycle duration
local offset = math.random() * blinkSpeed
local t = 0

local connection
connection = RunService.Heartbeat:Connect(function(dt)
    t += dt
    
    local phase = (t + offset) % blinkSpeed
    local on = phase < blinkSpeed/2
    
    script.Parent.Transparency = on and 0.25 or 1
    script.Parent.Decal.Transparency = on and 0 or 1
    
    if script.Stop.Value then
        connection:Disconnect()
        script:Destroy()
    end
end)

RunService will call that code every frame and give you the time that has passed since last frame, which you can use to count time while not being dependent on scheduler.

Thank you so much. This ended up working, I will make sure I remember this from now on.