Create Empty Server

  1. What do you want to achieve?
    There’s a role where you can pick to be a survivor or a killer, when the player pick as a killer I want to teleport the killer to an empty server or create an empty server

  2. What is the issue?
    I don’t know much about teleportation.

  3. What solutions have you tried so far?
    I look around in devforum and I only found about bugs on teleportation

I’m just wondering if you can teleport player to an empty server or create one so that there won’t be two killers in a server.

1 Like

Try using ReserveServer. The DevForum isn’t the only place to look!

There is another way to avoid this without needing teleportation (And that way is really better), You just check if there are more than a person with killer. If there is you can just delete the killer value of one of them and switch to survivor.

local ammountOfKillers = 0
local ingamePlayers = game.Players:GetPlayers()
local killers = {}
for _,v in pairs(ingamePlayers) do
      if v:FindFirstChild("Killer") then
            ammountOfKillers = ammountOfKillers + 1
            table.insert(killers, v)
      end
end 
local chosenKiller
if ammountOfKillers > 1 then
       repeat
       chosenKiller = math.random(1, #killers)
       killers[chosenKiller].Killer:Destroy()
       table.remove(killers, table.find(killers, killers[chosenKiller]))
       
       until #killers == 1
end

Or you can just do a thing that gives a killer value to a specify player and make it stop once someone got it.

local Teleport = game:GetService('TeleportService')
local Key = Teleport:ReserveServer(game.PlaceId)

local Killer = game.Players.Killer -- preset variable

Teleport.InitFailed:Connect(function(player, result, errorMessage)
     -- Handle teleport fails here.
end)

Teleport:TeleportToPrivateServer(game.PlaceId, Key, {Killer})
4 Likes