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

Round System Problems? - @TheDeadlyPanther or anyone else.

Asked by 8 years ago

So earlier I asked a question about my round system code saying that it isn't functional. Later on I got at least 2 responses about it, but it's still not working.

I was wondering if someone could check my code and see if there is a way to fix it. Thank you if you do! (If you can, please also show me a where I fix the code in Lua.)

function playerNotification(Text)
    for _,v in pairs (game.Players:GetChildren()) do
        local textLabel = v.PlayerGui:FindFirstChild("ScreenGui")
        if textLabel then
            textLabel.Frame.TextLabel.Text = Text
        end
    end
end

function waitForPlayers()
    while game.Players.NumPlayers < 2 do
        playerNotification("You need 1 more player to start the game.")
    end
end

function intermissionTimer()
    if game.Players.NumPlayers > 2 then
    for countDown = 10, 1, -1 do
        playerNotification("Intermission: " ..countDown)    
    end
end

function displayGamemode()

end

function mapSelection()
    local mapList = game.ReplicatedStorage.Maps:GetChildren()
    local randomMap = math.random(1, #mapList)
    playerNotification("Choosing the map!")
    wait(4)
    local mapChosen = mapList[randomMap]
    playerNotification("The map is: " ..mapChosen.Name)
    local mapClone = mapChosen:Clone()
    mapClone.Parent = game.Workspace
end

function teleportAllPlayers()
    local target = CFrame.new(workspace.SpawnLocation.Position)
    for i, player in ipairs(game.Players:GetChildren()) do
        player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
        player.Playing.Value = 1
    end
end

function startingTimer()
    for countDown = 3, 1, -1 do
        playerNotification("Game begins in: " ..countDown)
    end
end

function roundTimer()
    for countDown = 20, 1, -1 do
        playerNotification("Time left: " ..countDown)
    end
end

function roundEnded()

end

function teleportAlivePlayers()
    local target = CFrame.new(workspace.TeleportTarget.Position)
    for i, player in ipairs(game.Players:GetChildren()) do
        player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
        player.Playing.Value = 0
    end
end

function mapDestroy()

end

function showResults()

end

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            player.Playing.Value = 0
        end)
    end)

    local playing = Instance.new("IntValue", player)
    playing.Value = 0
    playing.Name = "Playing"
end)

while(true) do
      waitForPlayers()
      wait(0)
      intermissionTimer()
      wait(0)
      displayGamemode()
      wait(5)
      mapSelection()
      wait(5)
      teleportAllPlayers()
      wait(0)
      startingTimer()
      wait(0)
      roundTimer()
      wait(0)
      roundEnded()
      wait(0)
      teleportAlivePlayers()
      wait(0)
      mapDestroy()
      wait(0)
      showResults() 
   end
end
0
You aren't providing the point where the script errors. Also, if you ask a question in this way, everyone is open to answer - don't mention specific ones. Marios2 360 — 8y

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

In your intermissionTimer function, you're missing an end. There should be one for the end of the for loop.

function intermissionTimer()
    if game.Players.NumPlayers > 2 then
    for countDown = 10, 1, -1 do
        playerNotification("Intermission: " ..countDown)    
    end
end

However, the reason your script isn't throwing an error is because you the end for the if then statement on the intermissionTimer is acting as a end for the for loop. As well as the end intended for ending the function, is ending the if then statement. What this means is all the way at line 113 is the end of the intermissionTimer function. Since intermissionTimer is not being called, nothing can be done in the while loop, thus your script goes inactive just holding functions waiting to be used.

How to fix this, you need to remove the end from line 112, and add an end at line 20. So now your intermissionTimer function should look like this,

function intermissionTimer()
    if game.Players.NumPlayers > 2 then
    for countDown = 10, 1, -1 do
        playerNotification("Intermission: " ..countDown)    
    end
    end
end
If this helped, leave an upvote and if it worked hit the accept answer button! Leave a comment if you have any other questions or need further explanation somewhere.
Ad

Answer this question