I wish to understand why is there so many kicking cases even though I give 15 seconds till they get kicked, they should be teleported by then? My logs are reporting ton of the “x got kicked due to a teleportation error (TESTING) (1)”
Players = script:WaitForChild("Players")
Busy = script:WaitForChild("Busy")
PlaceId = script:WaitForChild("PlaceId")
PlayersNeeded = script:WaitForChild("PlayersNeeded")
Range = script:WaitForChild("Range")
LoopStop = script:WaitForChild("LoopStop")
Pad = script.Parent
Events = game.ReplicatedStorage:WaitForChild("Events")
game.Players.PlayerRemoving:Connect(function(PlayerWhoLeft)
if Players:FindFirstChild(PlayerWhoLeft.Name) then
Players:FindFirstChild(PlayerWhoLeft.Name):Destroy()
end
end)
while wait() do
if Busy.Value == false then
script.Parent.BillboardGui.TextLabel.Text = tostring(#Players:GetChildren()).."/"..tostring(PlayersNeeded.Value)
for i,v in pairs(game.Workspace:GetDescendants()) do
if v.Name == "HumanoidRootPart" then
local Magnitude = (v.Position - Pad.Position).Magnitude
if Magnitude <= 13 then
if #Players:GetChildren() < PlayersNeeded.Value then
local Player = game.Players:GetPlayerFromCharacter(v.Parent)
if Player ~= nil then
if not Players:FindFirstChild(Player.Name) then
local s = Instance.new("BoolValue")
s.Name = Player.Name
s.Parent = Players
end
end
elseif #Players:GetChildren() == PlayersNeeded.Value then
Busy.Value = true
local function SetBusyToFalse()
repeat wait() until #Players:GetChildren() == 0
Busy.Value = false
end
delay(0,SetBusyToFalse)
end
else
local Player = game.Players:GetPlayerFromCharacter(v.Parent)
if Player ~= nil then
if Players:FindFirstChild(Player.Name) then
Players:FindFirstChild(Player.Name):Destroy()
end
end
end
end
end
else
if LoopStop.Value == false then
LoopStop.Value = true
local success, errorMessage = pcall(function()
Code = game:GetService("TeleportService"):ReserveServer(PlaceId.Value)
end)
if success then
local ArrayOfPlayers = {}
script.Parent.BillboardGui.TextLabel.Text = "TELEPORTING!"
for i,v in pairs(game.Players:GetChildren()) do
if script.Players:FindFirstChild(v.Name) then
table.insert(ArrayOfPlayers,v)
v.Backpack.LocalValues.Teleporting.Value = true
Events:FindFirstChild("TeleportingEvent"):FireClient(v, "Activate")
end
end
local success2, errorMessage2 = pcall(function()
return game:GetService("TeleportService"):TeleportToPrivateServer(PlaceId.Value,Code,ArrayOfPlayers)
end)
if success2 then
for i,v in pairs(ArrayOfPlayers) do
local function Kick(PlayerX)
if game.Players:FindFirstChild(PlayerX.Name) and workspace:FindFirstChild(PlayerX.Name) and PlayerX.Backpack.LocalValues.Teleporting.Value == true then
PlayerX:Kick("TELEPORT FAILED!")
local http = game:GetService("HttpService")
local date = os.date("!*t")
local Data = {
["content"] = PlayerX.Name.." got kicked due to a teleportation error (TESTING) ".."(1)"
}
Data = http:JSONEncode(Data)
--http:PostAsync("", Data)
end
end
local function DelayThat()
Kick(v)
end
delay(15,DelayThat)
end
repeat wait() until #Players:GetChildren() == 0
LoopStop.Value = false
elseif errorMessage2 then
print(errorMessage2)
for i,v in pairs(ArrayOfPlayers) do
local function Kick(PlayerX)
if game.Players:FindFirstChild(PlayerX.Name) and workspace:FindFirstChild(PlayerX.Name) and PlayerX.Backpack.LocalValues.Teleporting.Value == true then
PlayerX:Kick("TELEPORT FAILED!")
local http = game:GetService("HttpService")
local date = os.date("!*t")
local Data = {
["content"] = PlayerX.Name.." got kicked due to a teleportation error (TESTING) ".."(2)"
}
Data = http:JSONEncode(Data)
--http:PostAsync("", Data)
end
end
local function DelayThat()
Kick(v)
end
delay(0,DelayThat)
end
repeat wait() until #Players:GetChildren() == 0
LoopStop.Value = false
end
elseif errorMessage then
print(errorMessage)
local ArrayOfPlayers = {}
for i,v in pairs(game.Players:GetChildren()) do
if script.Players:FindFirstChild(v.Name) then
table.insert(ArrayOfPlayers,v)
end
end
for i,v in pairs(ArrayOfPlayers) do
local function Kick(PlayerX)
if game.Players:FindFirstChild(PlayerX.Name) and workspace:FindFirstChild(PlayerX.Name) and PlayerX.Backpack.LocalValues.Teleporting.Value == true then
PlayerX:Kick("TELEPORT FAILED!")
local http = game:GetService("HttpService")
local date = os.date("!*t")
local Data = {
["content"] = PlayerX.Name.." got kicked due to a teleportation error (TESTING) ".."(3)"
}
Data = http:JSONEncode(Data)
--http:PostAsync("", Data)
end
end
local function DelayThat()
Kick(v)
end
delay(0,DelayThat)
end
repeat wait() until #Players:GetChildren() == 0
LoopStop.Value = false
end
end
end
end