hi, so I’ve posted about this before but I wasn’t really too clear on the old post, so I am posting about it again with a better wording in hopes of getting better results.
So basically, the game “rooms” by nicorocks5555 locks a server after the game starts. You open a door, and the server locks. You can’t join it, if you attempt to, it’ll kick you. But if you play the game normally without trying to join a specific server, it’ll create a new one and let others join that one until it locks.
Sorry if that didn’t make much sense, I recommend trying it out yourself.
I tried this code, but it doesn’t seem to work as intended
script.Parent.Door.MainDoor.ProximityPrompt.Triggered:Connect(function()
if DoorStatus == "Closed" and Debounce == false then
print('[ SERVER ]: Server has been locked, have fun')
local function onPlayerAdded(player: Player)
player:Kick('The game has already started!')
end
Players.PlayerAdded:Connect(onPlayerAdded)
end
end)
It kicks players who try to join it, but it does not create a new server when joining the game normally. Is there any way to create a new server after another one locks? I heard some things about TeleportService but I’m not sure how to go about it.
i have a general idea, however, this doesn’t really answer my question. I’m not sure how to exactly go about implementing this for my specific case. Any advice?
i think you could save the reserved access code when the door not locked, and after it got locked you will want to make new reserved access code and use the new code until the door is locked again.
maybe something like this?
local SavedAccessCode = nil
local TeleportService = game:GetService("TeleportService")
local placeId = nil --put your placeid here
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true
local teleportOptions2 = Instance.new("TeleportOptions")
teleportOptions2.ShouldReserveServer = false
local function updateTP2()
teleportOptions2.ReservedServerAccessCode = SavedAccessCode[2]
teleportOptions2.ServerInstanceId = SavedAccessCode[1]
end
local function CreateServerAndTeleportPlayer(players)
-- Teleport the player to a reserved server
local teleportResult = TeleportService:TeleportAsync(placeId,players, teleportOptions)
-- Save the ReservedServerAccessCode from the TeleportResult instance
SavedAccessCode = {teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode}
updateTP2()
end
local function TeleportPlayer(player)
TeleportService:TeleportAsync(placeId,{player}, teleportOptions2)
end
script.Parent.Door.MainDoor.ProximityPrompt.Triggered:Connect(function()
if DoorStatus == "Closed" and Debounce == false then
print('[ SERVER ]: Server has been locked, have fun')
local function onPlayerAdded(player: Player)
player:Kick('The game has already started!')
end
Players.PlayerAdded:Connect(onPlayerAdded)
else
CreateServerAndTeleportPlayer({player})
end
end)
this is giving me the exact same results, i did what you did (with some modifications since the code i posted isn’t the full thing) and it’s still kicking players and not reserving a server
local ServerClosed = false
script.Parent.Door.MainDoor.ProximityPrompt.Triggered:Connect(function()
if DoorStatus == "Closed" and Debounce == false then
print('[ SERVER ]: Server has been locked, have fun')
ServerClosed = true
end
end)
game.Players.PlayerAdded:Connect(function(dude)
if ServerClosed == true then
dude:Kick('The game has already started!')
end
end)