Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

7 comments

0

Paste your code you want to repeat inside a function and recall the function

0

how would that work in this situation, im really confused

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.

0

Those two functions will keep repeating eachother

0

do you have a discord show I can show you what I am doing

0

Yes

0

what is it

This discussion is preserved as it was. New answers, comments, and votes are closed.