Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to connect a wait timer to a overhead gui?

I made a script that makes it so you can walk for 30 seconds when a dev product is purchased. (It just sets the walk speed to 16 then wait(30) then sets it back to 0) I want the timer to be displayed overhead of the player so they can see their remaining time. How can I do this?

1 answer

Use a for loop from 30 to 0 with a step of -1, on each iteration wait one second. Use the variable (i) as it will tell you which iteration the timer is currently on.

local label = someTextLabel
-- ...

-- then when the player buys the product,
humanoid.WalkSpeed = 16 -- set the walk speed
for i = 30,0,-1 do -- i will be equal to a number between 30 and 0 inclusively
    label.Text = i
    task.wait(1)
end
humanoid.WalkSpeed = 0 -- remove the walk speed

5 comments

0

Thank you! Let me try that out

0

I'm getting Unknown global ' humanoid ' error for both humanoids in line 6 and 10

0

Yeah you have to define the humanoid yourself through the player's character.

0

How can I do that?

0

Use the player's character property.

This discussion is preserved as it was. New answers, comments, and votes are closed.