I make a game like doors and i want to make a server system.
If they go into an elevator anyone can join them while they are in a game, i dont need it to be like that.
I need players who enter the same elevator to be teleported into the same game and so nobody could join them. For now they do get teleported but anyone can join them if they get teleported too. That makes a mess.
local telePart = script.Parent
local TeleportService = game:GetService('TeleportService')
local placeID = (11873076445)
--replace this part
local canTeleport = true
local function otherGame(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player and canTeleport then
canTeleport = false
TeleportService:Teleport(placeID, player)
wait(0.01) --cooldown time
canTeleport = true
end
end
telePart.Touched:Connect(otherGame)
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Player = game.Players.LocalPlayer
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local PlrTable = {}
table.insert(PlrTable, hit.Parent.Name)
Event:FireServer(PlrTable)
end
end)
And our Server Script inside ServerScriptService
local TS = game:GetService("TeleportService")
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(Players)
local code = TS:ReserveServer(0)
TS:TeleportToPrivateServer(0, code, {Players})
end)
I hope i helped!
I did this on my phone so i don’t think it will work.