I have read a lot of topics here about this issue, but none of them seems to work for me. Is there something I do wrong? I have the original code down below and a screen of whats going on!
It needs to bring the player to the cloned bus, only when you spawn the bus it is falling apart (breaking in million pieces). After 3 seconds I get this error: Infinite yield possible on ‘Workspace.4010Original.A-Chassis Tune:WaitForChild(“Plugins”)’
while wait(0.25) do
for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
for i, q in pairs(v.Frame:GetChildren()) do
if q:IsA("TextButton") then
q.MouseButton1Down:Connect(function()
local bus = q.Text
local plr = script.Parent.Parent.Parent.Parent.Parent
if workspace:FindFirstChild(plr.Name .. "'s bus") then
workspace:FindFirstChild(plr.Name .. "'s bus"):Destroy()
end
print(v.Name)
if workspace.Fastnet.Bussen:FindFirstChild(v.Name) and workspace.Fastnet.Bussen:FindFirstChild(v.Name):FindFirstChild(bus) then
local ClonedBus = workspace.Fastnet.Bussen:FindFirstChild(v.Name):FindFirstChild(bus):Clone()
ClonedBus.PrimaryPart = ClonedBus:WaitForChild("DriveSeat")
ClonedBus:SetPrimaryPartCFrame(CFrame.new(Vector3.new(319.796, 45.825, -280.945)))
ClonedBus.Parent = workspace
ClonedBus.Name = plr.Name .. "'s bus"
plr.Character:SetPrimaryPartCFrame(ClonedBus.DriveSeat.CFrame)
script.Parent.Parent:Destroy()
end
end)
end
end
end
end
end
while wait(0.25) do
for _, v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
for _, q in pairs(v.Frame:GetChildren()) do
if q:IsA("TextButton") then
q.MouseButton1Down:Connect(function()
local bus = q.Text
local plr = script.Parent.Parent.Parent.Parent.Parent
local existingBus = workspace:FindFirstChild(plr.Name .. "'s bus")
if existingBus then
existingBus:Destroy()
end
local originalBus = workspace.Fastnet.Bussen:FindFirstChild(v.Name):FindFirstChild(bus)
if originalBus then
local originalDriveSeat = originalBus:FindFirstChild("DriveSeat") or originalBus:FindFirstChild("VehicleSeat")
if originalDriveSeat then
local clonedBus = originalBus:Clone()
clonedBus.Parent = workspace
clonedBus.Name = plr.Name .. "'s bus"
clonedBus.PrimaryPart = clonedBus:WaitForChild("DriveSeat")
local clonedDriveSeat = clonedBus:FindFirstChild("DriveSeat") or clonedBus:FindFirstChild("VehicleSeat")
if clonedDriveSeat then
clonedBus:SetPrimaryPartCFrame(originalDriveSeat.CFrame * CFrame.new(-20, 5, 0))
clonedBus:SetAttribute("Anchored", true)
local function anchorPartsAndMeshes(group)
if group then
for _, part in pairs(group:GetDescendants()) do
if part:IsA("BasePart") then
part.Anchored = true
end
end
end
end
anchorPartsAndMeshes(clonedBus:FindFirstChild("Body"))
anchorPartsAndMeshes(clonedBus:FindFirstChild("Misc"))
anchorPartsAndMeshes(clonedBus:FindFirstChild("Wheels"))
plr.Character:SetPrimaryPartCFrame(clonedDriveSeat.CFrame)
script.Parent.Parent:Destroy()
end
end
end
end)
end
end
end
end
end