Puppet box Roblox remake

Hi developers. So im try to remake puppet music box from FNAF 2. But idk how to do this correctly, first idea which come to my head is make timer with loop for which counting for example 100 sec and if player holding button then loop stop where he stop counting and going in reverse to 100.


[What do you want to achieve?]
I want to remakepuppet music box system like in FNAF 2. When we must keep puppet asleep with winding her box to prevent the waking her and kill us.
[What is the issue?]
Currently my friend help me to make script

local prompt = script.Parent.ProximityPrompt
local text = script.Parent.SurfaceGui.Timer
local status = script.Parent.Status.Value


function WindUp()
	status = "up"
	prompt.ActionText = "Wind down"
	repeat
		print(text.Text)
		wait(1)
		text.Text +=1
	until text.Text == "20" or status == "down"
end


function WindDown()
	status = "down"
	prompt.ActionText = "WindUp"
	repeat 
		print(text.Text)
		wait(1)
		text.Text -=1
	until text.Text == "0" or status == "up"
end

prompt.Triggered:Connect(function()
	if status == "up" then
		WindDown()
	elseif status == "down" then
		WindUp()
	end
end)

[What solutions have you tried so far?]
At the beginning of i was make two loops which one is counting 100 sec.(before i ask my friend to help me make script).And if player holding some button then loop stoped and second start counting instead of first one.
Above code is working almost right but it still buggy. Can someone help do this more correctly.
There in a part my code
source

1 Like

I know the Forgotten memories have this system. So i want to make too.

If I read it right, you click once to start winding up, and once again to wind down, like a toggle. Isn’t the point of the puppet box to need to be held down?

Yeah but I was mention this above.