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

Can I have a 'Time Remaining: ' part added to this script?

Asked by
awfulszn 394 Moderation Voter
9 years ago

I am making a sword game and everything works, but during the actual game, I want the status bar to tell everybody how long is left, the wait(300) at the bottom is how long the match lasts. Here is the script:

local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage:WaitForChild('InfoValue')
local mapstorage = game.Workspace:WaitForChild('MapStorage')
while true do

while game.Players.NumPlayers < 2 do
    status.Value = 'There needs to be 2 or more players to begin!'
    repeat wait(2) until game.Players.NumPlayers <= 2
end

for i = 120,0,-1 do
    status.Value = 'Intermission: '..i
    wait(1)
end

local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren()
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
chosenmap:Clone().Parent = mapstorage
status.Value = 'Get ready to be teleported!'
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(randomspawn.Position + Vector3.new(0,2,0))

            local sword = game.ReplicatedStorage.Sword
            local newsword = sword:Clone()
            newsword.Parent = player.Backpack
        end
    end
end





wait(300)




mapstorage:ClearAllChildren()
end

2 answers

Log in to vote
0
Answered by 9 years ago
local left = 300

repeat
left = left - 1
status.Value = "Time remaining:"..left --time left
wait(1)
until left == 0
0
I added a wait(1) before the until left == 0 and it works :) awfulszn 394 — 9y
0
Your welcome my kind friend :) legomaster38 39 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

You could add this on Line 42 (remove the wait()):

local left = 300

repeat
left = left - 1
print(left) -- time left
until left == 0
0
I want the status bar to say the amount of time remaining though. awfulszn 394 — 9y

Answer this question