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

Timer text not changing?

I am using a hint to show the intermission time or round time In my game. When I join, nothing appears.

Code:

-- Main Game Script for Sword Fighting Arena

local timer = Instance.new("Hint")
local interTime = 30 -- intermission time in seconds
local roundTime = 180
local gameMode = "Intermission"
timer.Parent = game.Workspace

-- Necessary functions
local chosenMap = Instance.new("IntValue")
local newMap = function()
	local map
	local message
	chosenMap.Value = math.random(1) -- range of 1 and the number of maps i.e 1,3
	
	-- Get the map from replicated storage of the chosen map and clone it to workspace
	if chosenMap.Value == 1 then
		-- Generate a message saying the chosen map
		message = Instance.new("Message")
		message.Text = "The chosen map is Classic!"
		message.Parent = game.Workspace
		wait(2)
		message:Destroy()
		
		-- Clone the map to the workspace
		map = game.ReplicatedStorage.Classic:Clone() -- clone to the workspace
		map.Parent = game.Workspace
	end
end

local decrementTimer = function()
	wait(1)
	if gameMode == "Intermission" then
		if interTime < 0 then
			gameMode = "Round"
			interTime = 30
		else
			timer.Text = ("Intermission time: " + tostring(interTime))
			interTime = interTime - 1
		end
		
	elseif gameMode == "Round" then
		if roundTime < 0 then
			gameMode = "Intermission"
			roundTime = 180
		else
			timer.Text = ("Round time: " + tostring(roundTime))
			roundTime = roundTime - 1
		end
	end
end

-- Main game loop
while true do
	wait(1)
	decrementTimer()
end

Thanks in advance.

1 answer

Consider using a value instead of arithmetic on a string as it won't work, which causes your script, in lines 38 - 56 to not function properly. When using a value, you can also do many more things with the value, such as doing other things with local Gui's or where ever your imagination takes you.

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