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

Why isn't my timer script isn't working?

Asked by 8 years ago

I am working on a timer script, but when I try to change a hint's text or a gui text it won't work, in this case I am using a hint, but I have tried with a gui and i still fail, I have even tried strings.

hint = Instance.new("Hint")
hint.Parent = game.Workspace
guilabel = hint.Text
waiting = game.ServerStorage.waiting.Value
intermission = 30
gametimer = 60
gametype = game.ServerStorage.gametype.Value
wait(1)
guilabel = "text"
while true do
    wait(1)
    if waiting == true then
        if intermission > -1 then
            guilabel = "Intermission " ..intermission --making hint say "Intermission (number)"
            intermission = intermission - 1
            print(intermission) --printing it to test
        else
            waiting = false
            intermission = 30 --reseting the intermission
        end 
    elseif gametype == 1 then
        if gametimer > -1 then
            guilabel = gametimer --same thing here
            gametimer = gametimer - 1
            print(gametimer)
        else
            waiting = true
            gametimer = 60 -- reseting
        end
    end
end
0
can you show the output errors? wackem 50 — 8y
0
there weren't any, it just wasn't changing the hint redyred234 0 — 8y

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

Your problem has to do with your variable guilabel. What you have done is set it to the value stored in hint's Text property. To make this work correctly, you should set hint.Text to whatever you want it to be.

Example:

local hint = Instance.new("Hint")
hint.Text = "The text you want"

Rather than:

local hint = Instance.new("Hint")
local text = hint.Text -- Stores the value in the variable
text = "Updates variable value, not the hint's Text"
Ad

Answer this question