How do i make a countdown

Hi what im trying to do is make a countdown to when the cube starts spinning

When i tried a fix i thought of it didnt work (probably because i wrote it in js lol)

This is the code i have

while wait(60) do
         script.Text.Value = "Cube is spinning, avoid all calamities coming across your way." 
         wait(3)
         script.Text.Value = "Cube is spinning." 
         for _ = 0, (40*4) * 3 do
                  wait()
                  script.Parent.PrimaryPart.CFrame = script.Parent.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(0.1 ), math.rad(0.1 ), math.rad(0.1 ))
         end
         script.Text.Value = "Cube starts spinnin in 60 seconds"
end

Note: I didnt make this
Could Someone help please

1 Like

What’s not working about it? Is there an error?

Also, a simple way of doing a countdown is:

for i = 30, 0, -1 do
    
script.Parent.Text = i

Along with, your script is really over-complicated.

2 Likes

Here’s a simple way to do a countdown:

local Start = 10 -- Number which it starts counting down from
for Number = Start, 0, -1 do
      script.Parent.Text = Number;
end;

Replace the while wait(60) do with while true do and run the countdown inside the loop instead.

while (true) do
    script.Text.Value = "Cube is spinning, avoid all calamities coming across your way."
    wait(3)
    script.Text.Value = "Cube is spinning."
    for _ = 0, (40*4) * 3 do
        wait()
        script.Parent.PrimaryPart.CFrame = script.Parent.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(0.1 ), math.rad(0.1 ), math.rad(0.1 ))
    end
    for i = 60, 1, -1 do
        script.Text.Value = "Cube starts spinning in "..i.." seconds."
        wait(1)
    end
end

Also, using a yielding function inside the condition of the while loop is a bad habit to learn. you can read about it here:

1 Like

if you look at the end you can see i said i didnt make the code