Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Whats wrong with this script? No errors i've tried everything.

Asked by 7 years ago

local replicatedstorage = game:GetService("ReplicatedStorage") local status = replicatedstorage:WaitForChild("InfoValue") local mapStorage = game.Workspace:WaitForChild("mapStorage")

while true do

while game.Players.NumPlayers > 1 do
    status.Value = "There must be 2 or more players to play"
    repeat wait(2) until game.Players.numPlayers <= 2       
end

for i = 1,0,-1 do
    status.Value = "Intermision "..i
    wait(1)
end
_G.gameplayers = {}
for i, v in pairs(game.Players:GetPlayers()) do

    if v then
        table.insert(_G.gameplayers, v.Name)
    end
end

local maps = game:GetService("ServerStorage"):GetChildren()
local chosenmap = maps[math.random(1, #maps)]
chosenmap:Clone().Parent = mapStorage
status.Value = "Get Ready!!"
wait(3)
local spawns = chosenmap:WaitForChild("Spawns"):GetChildren()
for _, player in pairs(game.Players:GetPlayers()) do
    if player and #spawns > 0 then
        local torso = player.Character:WaitForChild("Torso")
        local allspawns = math.random(1 ,#spawns)
        local randomspawn = spawns[allspawns]
        if randomspawn and torso then
            table.remove(spawns, allspawns)
            torso.CFrame = CFrame.new(game.ServerStorage.WaterFall.Spawns.Model.Part.Position + Vector3.new(0,2,0))

            local FireBall = game.ReplicatedStorage.FireBall
            local newFireBall = FireBall:Clone()
            newFireBall.Parent = player.Backpack
        end
    end
end
for i = 60,0,-1 do
    status.Value = i.."  Seconds Left!"
    if i == 0 then
status.Value = "Times up"
for _, player in pairs(game.Players:GetPlayers()) do 
    if player:FindFirstChild("leaderstats") then
        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 2
        end
    end
    break
   else

end

end
for i = 60,0,-1 do wait(1)
    if i == 0 then 
        status.Value = "Times up!!"
        break
    end

    wait(1)
    if #_G.gameplayers == 1 then
        for i, v in pairs(_G.gameplayers) do
            if v ~= nil then
                status.Value = v.." is the winner!"
                break
            end
        end
        break
    else
        status.Value = i.." seconds remaining"
    end

end
mapStorage:ClearAllChildren()   
wait(5)

end

The thing that isn't working is THe round is for 1 second long... instead of 60

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

use a while wait() loop so it can constantly detects if there is enough players.

Ad

Answer this question