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

how do I restart a script when a round is over?

Asked by
zValerian 108
5 years ago

so I've been working on a game that has rounds and intermission. What I am trying to do is that when round ends, it fires intermission and then it starts again. Here is the script I want to fire when the intermission is over.

function update(count)
    local player = game.Players.LocalPlayer
    game.Players.LocalPlayer.PlayerGui.pods.ann.TextButton.Text = "Waiting for "..count.." more players!"
    if count <= 0  and game.Workspace.game.CanCollide == true then
        game.Players.LocalPlayer.PlayerGui.pods.ann.Visible = true
        game.Players.LocalPlayer.PlayerGui.pods.ann.TextButton.Text = "Welcome to the annual HUNGER GAMES"
        wait(10)
        game.Players.LocalPlayer.PlayerGui.pods.ann.TextButton.Text = "If you don't know how to play, read the description!"
        wait(10)
        player.TeamColor = BrickColor.new("Forest green")
        game.Players.LocalPlayer.PlayerGui.pods.ann.TextButton.Text = "Selecting random arena..."
        wait(5)
        game.Players.LocalPlayer.PlayerGui.pods.ann.TextButton.Text = "Arena selected. Prepare to enter the game. May the odds be ever in your favor."
        wait(20)
        game.Players.LocalPlayer.PlayerGui.pods.ann.Visible = false
        local Pos = player.Character:GetPrimaryPartCFrame()
                    player:LoadCharacter()
                    player.Character:SetPrimaryPartCFrame(Pos)
                    if player.Character:FindFirstChild("ForceField") then
                        player.Character["ForceField"]:Destroy()
                        wait(1)
                        game.ReplicatedStorage.Remotes.tp:FireServer()
game.Workspace.game.CanCollide = false
                    end
    end
    end

game.ReplicatedStorage.Notify.OnClientEvent:connect(update)


here is the script that I want to fire the script above.

local player = game.Players.LocalPlayer
game.Players.LocalPlayer.PlayerGui.pods.ann.Visible = true
game.Players.LocalPlayer.PlayerGui.pods.ann.TextButton.Text = "Intermission.."
wait(30)
game.Players.LocalPlayer.PlayerGui.pods.ann.Visible = false
game.Workspace.game.CanCollide = true
local Pos = player.Character:GetPrimaryPartCFrame()
                    player:LoadCharacter()
                    player.Character:SetPrimaryPartCFrame(Pos)
                    if player.Character:FindFirstChild("ForceField") then
                        player.Character["ForceField"]:Destroy()
                game.Workspace.inter.CanCollide = false
                game.ReplicatedStorage.Remotes.start:FireServer()
                    end


Do any of you have any ideas? I am lost. Any help will be appreciated.

1 answer

Log in to vote
0
Answered by 5 years ago

You can easily loop functions by firing the function again.

Example:

function createPart()
    Instance.new("Part", workspace)
    wait(1)
    createPart()
end

Basically works like a while wait(), while true, etc.

0
Paste your code you want to repeat inside a function and recall the function awesomeipod 607 — 5y
0
how would that work in this situation, im really confused zValerian 108 — 5y
0
At the end of your intermission function, put your start round function there. In the start round function, fire the intermission function when the round is finished. awesomeipod 607 — 5y
0
Those two functions will keep repeating eachother awesomeipod 607 — 5y
View all comments (3 more)
0
do you have a discord show I can show you what I am doing zValerian 108 — 5y
0
Yes awesomeipod 607 — 5y
0
what is it zValerian 108 — 5y
Ad

Answer this question