So I am making a story game and sometimes when you are being teleported from the lobby to the main game, Roblox just freezes at the loading screen and stops responding…
This happens only to some people and rest of the people are successfully teleported to the main game, here is how they will see the people whose game is frozen
And here is what the person who froze will see.
Is there any way to fix it? Here’s my bus teleportation code…
local teleportService = game:GetService('TeleportService')
local players = game:GetService('Players')
local hitBox = script.Parent
local seats = workspace.Bus2:WaitForChild('Seats')
local status2 = workspace:WaitForChild('Status2')
local billBoard = status2:WaitForChild('BillboardGui')
local joinable = true
local busTable = {}
hitBox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local player = players:GetPlayerFromCharacter(hit.Parent)
for _, seat in pairs(seats:GetChildren()) do
if seat.Occupant == nil and joinable and not table.find(busTable,player) then
table.insert(busTable,player)
hit.Parent.Humanoid.JumpPower = 0
seat:Sit(hit.Parent.Humanoid)
game.ReplicatedStorage.BusGui:FireClient(player)
hitBox.PlayerCount.Value = #busTable
break
end
end
end
end)
game.ReplicatedStorage.BusLeave.OnServerEvent:Connect(function(player)
local returnValue = table.find(busTable,player)
if returnValue then
table.remove(busTable,returnValue)
player.Character.Humanoid.JumpPower = 50
player.Character.Humanoid.Sit = false
hitBox.PlayerCount.Value = #busTable
wait(.4)
player.Character.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0,2,0)
end
end)
hitBox.PlayerCount:GetPropertyChangedSignal('Value'):Connect(function()
billBoard.Frame.Players.Text = 'Players: '..hitBox.PlayerCount.Value..'/6'
end)
coroutine.wrap(function()
while true do
for i = 30,0,-1 do
if #busTable >= 6 then
break
end
billBoard.Frame.Timer.Text = 'Time: '..i
wait(1)
end
if #busTable < 1 then
billBoard.Frame.Status.TextColor3 = Color3.fromRGB(255,0,0)
billBoard.Frame.Status.Text = '2 Players needed!'
wait(2.5)
billBoard.Frame.Status.Text = 'Enter Bus'
billBoard.Frame.Status.TextColor3 = Color3.fromRGB(17, 255, 0)
else
joinable = false
billBoard.Frame.Status.TextColor3 = Color3.fromRGB(255,0,0)
billBoard.Frame.Status.Text = 'Teleporting!'
billBoard.Frame.Status.TextColor3 = Color3.fromRGB(62, 197, 255)
local code = teleportService:ReserveServer(5839294170)
teleportService:TeleportToPrivateServer(5839294170,code,busTable)
for _, player in pairs(busTable) do
game.ServerStorage.FadeUI:Clone().Parent = player.PlayerGui
end
repeat wait() until #busTable == 0
billBoard.Frame.Status.TextColor3 = Color3.fromRGB(17, 255, 0)
billBoard.Frame.Status.Text = 'Enter Bus'
joinable = true
end
end
end)()
players.PlayerRemoving:Connect(function(player)
local returnValue = table.find(busTable,player)
if returnValue then
table.remove(busTable,returnValue)
hitBox.PlayerCount.Value = #busTable
end
end)```