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 comment
oh thats a horrible mistake i made because i was detecting if textcounter.text was "0" thanks for telling me this