Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Map selector not selecting maps after 0 seconds?

Asked by 9 days ago

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

Log in to vote
1
Answered by 9 days ago

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

0
oh thats a horrible mistake i made because i was detecting if textcounter.text was "0" thanks for telling me this antoniorigo4 99 — 9d
Ad

Answer this question