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

ReserveServer not working, Code same as wiki?

I'm making a camping type game and I'm using Reserve server to make a new server so players can't go to the same server, I wrote the code and it doesn't work, I browsed over 50+ pages and it's still not working, Can anyone help me?

Code:

local teleportService = game:GetService("TeleportService")

local code = teleportService:ReserveServer(7140418017)

teleportService:TeleportToPrivateServer(7140418017, code, unpack(plrs)) -- getting every player in a table and teleporting them

Full Code:

local teleportService = game:GetService("TeleportService")

local code = teleportService:ReserveServer(7140418017)

local plrs = {}

local buttonPart =game.Workspace:FindFirstChild("MainLobby"):FindFirstChild("TouchParts"):FindFirstChild("TouchPart2")

local infoPart = game.Workspace:FindFirstChild("MainLobby"):FindFirstChild("InfoPart2")

local infoText = infoPart:FindFirstChild("SurfaceGui"):FindFirstChild("TextLabel")

local bus = game.Workspace:FindFirstChild("MainLobby"):FindFirstChild("Buses"):FindFirstChild("Bus2")

local teleportPart = bus:FindFirstChild("TPPart")

local cooldown = false

local timer = 30

game:GetService("Players").PlayerAdded:Connect(function(player)
	
	player:WaitForChild("PlayerGui"):WaitForChild("LeaveGui"):WaitForChild("LeaveButton").MouseButton1Click:Connect(function()
		
		player.Character:WaitForChild("Humanoid").Health -= 100
		
		table.remove(plrs, table.find(plrs, player))
		
		player:WaitForChild("PlayerGui"):WaitForChild("LeaveGui").Enabled = false
		
	end)
	
end)

buttonPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if cooldown == false then
			
			cooldown = true
			
			local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		
			local char = hit.Parent
			
			table.insert(plrs, player)
		
			char:WaitForChild("HumanoidRootPart").CFrame = teleportPart.CFrame
			
			player:WaitForChild("PlayerGui"):WaitForChild("LeaveGui").Enabled = true
			
			wait(1)
			
			cooldown = false
			
		end
	end
end)

while true do
	
	wait()
	
	for i = timer,0,-1 do
		infoText.Text = "Time until leaving: "..i.." Players: "..#plrs
		wait(1)
	end

	cooldown = false

	infoText.Text = "Teleporting..."
	
	teleportService:TeleportToPrivateServer(7140418017, code, plrs)

	wait(10)

	cooldown = true
	
end

1 answer

:ReserveServer accepts a table of players, unpacking the table of players would return the players in a subsequent order.

You only have to pass the plrs variable, no need to unpack.

local teleportService = game:GetService("TeleportService")
 
local code = teleportService:ReserveServer(7140418017)

teleportService:TeleportToPrivateServer(7140418017, code, plrs)

5 comments

0

Expected identifier when parsing expression, got )

0

Are you sure you pasted your code exactly? I don't see any extra parentheses in my post or yours.

0

Thats weird

0

Sorry but it didn't work

0

I fixed the error but it doesn't work

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