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

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

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

COT = game.ReplicatedStorage.CorruptedTimer.Value
TCO = script.Parent
gameie = game.ReplicatedStorage.Game.Value
local mytable = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

if gameie == 5 then
TCO.Visible = true

for i, v in pairs(mytable) do
		TCO.Text = COT
		COT = COT -1 
	end
	TCO.Visible = false
end

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

3 answers

✓ Accepted answer

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.

local yourGUI =  script.Parent --Set your ScreenGUI or Frame.
local guiText = yourGUI.Text
gameie = game.ReplicatedStorage.Game.Value
local timer = 20

if gameie == 5 then
	yourGUI.Enabled = true --Do Visible or change the transparency if it isnt a ScreenGUI.
	while true do
		wait(1)
		timer   -= 1
		if timer == 0 then
			break
			yourGUI.Enabled = false
		end
	end
end

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

14 comments

0

Make the variables local! Don't do for do loop.

0

what does break mean

0

You use break to stop a while true do.

0

ok thank u

0

it says on line 13 that it expected end on line 11 to end then??? how do i fix??

0

Add 1 more end, to close that if statement.

0

Or, you can delete every end, and press enter after each function/event. That works 100%

0

ok

0

still didnt work

0

What is gameie, what is COT, what is TCO? Because i know what's the problem here.

0

it is an int value

0

they all are int values

0

and i am using a script not a local script is that a problem??

0

Yes, do it LocalScript. And every variable always local. Watch a basics video of Lua, it will help.

use a if statement

COT = game.ReplicatedStorage.CorruptedTimer.Value
TCO = script.Parent
gameie = game.ReplicatedStorage.Game.Value
local mytable = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

if gameie == 5 then
TCO.Visible = true

for i, v in pairs(mytable) do
        TCO.Text = COT
        COT = COT -1
	if COT == 0 then
		TCO.Visible = false
    end	    

end

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

COT = game.ReplicatedStorage.CorruptedTimer.Value
TCO = script.Parent
gameie = game.ReplicatedStorage.Game

gameie.Changed:Conect(function()
	if gameie.Value == 5 then
		TCO.Visible = true
		for i = 20,1,-1 do
	        TCO.Text = COT
			COT = COT -1 
			wait(1)
	    end
	    TCO.Visible = false
	end
end)

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