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

Map selector not selecting maps after 0 seconds?

I'm making a map selector for my game, The map gets selected but at 0 seconds it becomes negative and doesn't switch the map.

local timeleft = 25
local timecounter = Instance.new("Hint",workspace)
function mapselect()
	local random = math.random(1,#game.Lighting.Maps:GetChildren())
	if random == 1 then
		game.Lighting.Maps.forest.Parent = workspace	
		return "forest"	
	elseif random==2 then
		game.Lighting.Maps.neighbourhood.Parent = workspace	
		return "neighbourhood"	
	elseif random==3 then
		game.Lighting.Maps.house.Parent = workspace	
		return "house"	
	elseif random==4 then
		game.Lighting.Maps.city.Parent = workspace
	return "city"	
	end
end
mapselect()--start at game
coroutine.resume(coroutine.create(function()
	while true do wait(1)
	timeleft = timeleft -1
	timecounter.Text = "There is "..timeleft.." seconds left"
		if timeleft == "0" then
			timeleft = 25
			
			mapselect()
			for i,v in pairs(game.Players:GetDescendants()) do
				if v:IsA("Player") then
					v.Character.Humanoid.Health = 0
				end
			end
		end	
	end end))

1 answer

✓ Accepted answer

if timeleft == "0" then change the "0" into 0 timeleft is a number not a string

1 comment

0

oh thats a horrible mistake i made because i was detecting if textcounter.text was "0" thanks for telling me this

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