Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why won't timer work with string value thing yes?

Asked by 4 years ago
01local Time = "N/A"
02 
03while true do
04 
05    if script.Parent.Value == 0 then
06 
07        script.Parent.ClickDetector.MaxActivationDistance = 32
08 
09    else
10 
11        Time = script.Parent.Value - 1
12        wait(1)
13        script.Parent.Value = Time
14        script.Parent.SurfaceGui.TextLabel.Text = Time
15 
16    end
17 
18end
0
Please post a description. See https://idownvotedbecau.se/UnclearQuestion User#30567 0 — 4y
0
@cookie_more You don't need to know the script's parent in order for you to help. zane21225 243 — 4y

1 answer

Log in to vote
0
Answered by
zane21225 243 Moderation Voter
4 years ago

I see some things that I am able to fix up!

Here's the fixed code, let me know if it works!

01local Time = 'N/A'
02local timestart = 30 --how many seconds it counts down from
03 
04for i = timestart, 1, -1 do
05wait(1)
06Time = i
07script.Parent.Value = Time
08script.Parent.SurfaceGui.TextLabel.Text = Time
09end
10 
11script.Parent.ClickDetector.MaxActivationDistance = 32

Also, if you're using a Server Script then the TextLabel's text will probably not update. Try handling everything related to GUIs via LocalScripts.

0
You are correct for everything, except GUIs will update if changed from server. User#30567 0 — 4y
0
^ My bad! I've just had experience with them not working well with ServerScripts. Will note! zane21225 243 — 4y
Ad

Answer this question