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

Why wont my Timer go visible. It wont even change the text???(GUI)

Asked by 4 years ago

I am currently developing a game and for some reason my timer gui wont show up and count down here is my script...

01COT = game.ReplicatedStorage.CorruptedTimer.Value
02TCO = script.Parent
03gameie = game.ReplicatedStorage.Game.Value
04local mytable = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
05 
06if gameie == 5 then
07TCO.Visible = true
08 
09for i, v in pairs(mytable) do
10        TCO.Text = COT
11        COT = COT -1
12    end
13    TCO.Visible = false
14end

any other methods of triggering an event that makes a timer run????

3 answers

Log in to vote
0
Answered by 4 years ago

Just make a variable, you don't need a table. Do a variable and a while true do. And also you need to change the Text of the GUI.

01local yourGUI =  script.Parent --Set your ScreenGUI or Frame.
02local guiText = yourGUI.Text
03gameie = game.ReplicatedStorage.Game.Value
04local timer = 20
05 
06if gameie == 5 then
07    yourGUI.Enabled = true --Do Visible or change the transparency if it isnt a ScreenGUI.
08    while true do
09        wait(1)
10        timer   -= 1
11        if timer == 0 then
12            break
13            yourGUI.Enabled = false
14        end
15    end
16end

I really hope this works and helped! At least you have an idea of how to do it.

0
Make the variables local! Don't do for do loop. LetalNightmare 99 — 4y
0
what does break mean Lamborghinihurican0 4 — 4y
0
You use break to stop a while true do. LetalNightmare 99 — 4y
0
ok thank u Lamborghinihurican0 4 — 4y
View all comments (10 more)
0
it says on line 13 that it expected end on line 11 to end then??? how do i fix?? Lamborghinihurican0 4 — 4y
0
Add 1 more end, to close that if statement. LetalNightmare 99 — 4y
0
Or, you can delete every end, and press enter after each function/event. That works 100% LetalNightmare 99 — 4y
0
ok Lamborghinihurican0 4 — 4y
0
still didnt work Lamborghinihurican0 4 — 4y
0
What is gameie, what is COT, what is TCO? Because i know what's the problem here. LetalNightmare 99 — 4y
0
it is an int value Lamborghinihurican0 4 — 4y
0
they all are int values Lamborghinihurican0 4 — 4y
0
and i am using a script not a local script is that a problem?? Lamborghinihurican0 4 — 4y
0
Yes, do it LocalScript. And every variable always local. Watch a basics video of Lua, it will help. LetalNightmare 99 — 4y
Ad
Log in to vote
0
Answered by
I_Nev 200 Moderation Voter
4 years ago

Try this, when the game value in replicated changes it will update the function, you was only running the if statement once, and after that one time it would return false and not go ahead

01COT = game.ReplicatedStorage.CorruptedTimer.Value
02TCO = script.Parent
03gameie = game.ReplicatedStorage.Game
04 
05gameie.Changed:Conect(function()
06    if gameie.Value == 5 then
07        TCO.Visible = true
08        for i = 20,1,-1 do
09            TCO.Text = COT
10            COT = COT -1
11            wait(1)
12        end
13        TCO.Visible = false
14    end
15end)
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

use a if statement

01COT = game.ReplicatedStorage.CorruptedTimer.Value
02TCO = script.Parent
03gameie = game.ReplicatedStorage.Game.Value
04local mytable = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
05 
06if gameie == 5 then
07TCO.Visible = true
08 
09for i, v in pairs(mytable) do
10        TCO.Text = COT
11        COT = COT -1
12    if COT == 0 then
13        TCO.Visible = false
14    end    
15 
16end

Answer this question