I’m trying to make a part that teleports everyone inside of it to my game’s place
But for some reason, I keep getting this error
And then even weirder, I tried teleporting the player to a game thats not my own and it worked just fine.
So I can’t teleport anyone to a place inside of my game but I can do an entirely different game?
I made the place public and direct access is enabled so what’s going on?
local maxplayers = script.Parent:WaitForChild("Max")
local teleportserivce = game:GetService("TeleportService")
local current = script.Parent:WaitForChild("Current")
local neededplayers = 2
local currenttable = {}
local billboardgui = script.Parent:WaitForChild("BillboardGui")
local text = billboardgui:WaitForChild("TextLabel")
local counter = 12
local placeid = 105476987349801
local overlapParams = OverlapParams.new()
overlapParams.FilterDescendantsInstances = {script.Parent}
overlapParams.FilterType = Enum.RaycastFilterType.Exclude
while true do
task.wait(1)
counter -=1
print(counter)
if counter == 0 and #currenttable >= neededplayers then
local Success, Result = pcall(function()
return teleportserivce:TeleportAsync(placeid, currenttable)
end)
if Success then
table.clear(currenttable)
print("Players teleported to ", Result)
else
warn(Result)
end
counter = 12
elseif counter == 0 and #currenttable < neededplayers then
counter = 12
end
local parts = workspace:GetPartBoundsInBox(script.Parent.CFrame, script.Parent.Size, overlapParams)
for i,v in pairs(parts) do
if v.Parent:FindFirstChild("Humanoid") and not (#currenttable >= maxplayers.Value) then
if not table.find(currenttable, game.Players:GetPlayerFromCharacter(v.Parent)) then
table.insert(currenttable, game.Players:GetPlayerFromCharacter(v.Parent))
text.Text = #currenttable .. "/" .. maxplayers.Value .. " Players"
v.Parent.HumanoidRootPart.Position = workspace.Floor.Position + Vector3.new(0,2,0)
end
end
end
end
game.Players.PlayerRemoving:Connect(function(plr)
if table.find(plr.Character) then
table.remove(currenttable, table.find(currenttable,plr))
text.Text = #currenttable .. "/" .. maxplayers.Value .. " Players"
end
end)