How would i make a retry button?

Hello people. So at this point i want to make a Retry button, how it works is basically if all of the player in servers click it, it would teleport everyone to the same place. Is there a way i could do this?

1 Like

Check if anyone presses the button on a GUI then loop through all the players and set their position to the desired location or if it’s another game use teleportation service.

1 Like

First, create a button, create a RemoteEvent in ReplicatedStorage then create a LocalScript inside the button:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer() -- change to RemoteEvent position
end)

Create a Script in ServerScriptService to handle the remote:

local Teleport = game:GetService("TeleportService")
local tableOfPlayers = {}
local playerVotes = 0

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr) -- replace with remote location
	if not table.find(tableOfPlayers, plr.Name, 1) then -- if player not in table
		table.insert(tableOfPlayers, plr.Name)
		playerVotes += 1
	if playerVotes >= #game.Players:GetPlayers() then -- if all players voted
		local success, errorM = pcall(function()
			Teleport:TeleportAsync(000000, game.Players:GetPlayers()) -- replace 0 with place id
		end)
		if not success then
			warn("Error while teleporting: "..errorM)
		end
	end
end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.