Why won't my script update the other clock decals?

I’ve been trying to make a clock tower and made a script to rotate decals of hour and minute hands to a 1000x sped up 24h clock, but the script only detects one clock out of the four, is there any way to solve this?

There weren’t any errors or anything which made it more weird on why it only worked on one clock face, I changed the layout a bit and script location to see if that would help but that didn’t help much


local daynightscript = game:GetService("ServerScriptService"):FindFirstChild("Daynight", true)
print(daynightscript)

local collection = script.Parent
local multiplier = daynightscript.Attributes:GetAttribute("Multiplier")
local steps = multiplier
local deb1 = false
local deb2 = false
local minutetime = 0.1
local hourtime = 0.0083333333

game:GetService("RunService").Heartbeat:Connect(function()
	for _, minutehands in pairs(collection:GetDescendants()) do
		if minutehands:IsA("Decal") then
			if minutehands.Rotation >= 359 then
				minutehands.Rotation = 0
			end
		end
		if minutehands.Name == "MinuteHand" and minutehands:IsA("Decal") then
			if deb1 == true then return end
			deb1 = true
			minutehands.Rotation += minutetime / steps * multiplier
			task.wait(1/steps)
			deb1 = false
		end
		if minutehands.Name == "HourHand" and minutehands:IsA("Decal") then
			if deb2 == true then return end
			deb2 = true
			minutehands.Rotation += hourtime / steps * multiplier
			print(hourtime)
			task.wait(1/steps)
			deb2 = false
		end
	end
end)

1 Like

if deb1 == true then return end and if deb2 == true then return end

You’re probably looking for continue so that you don’t skip the rest of the for loops cycles.

Seemed to semi-work, it lets the other clock hands move but they all move out of sync now

I figured it out, I had too many Heartbeats running and the deb was there to try to lessen the load. I just removed a bunch of Heartbeats so I didn’t need to worry much on performance and just removed the debs which fixed it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.