-- Script 1 for i, v in pairs(workspace.Bus:GetChildren()) do if v:IsA "Model" then repeat wait() until v repeat wait() until v.Humanoid repeat wait() until game.Players:FindFirstChild(v.Name).PlayerGui repeat wait() until game.Players:FindFirstChild(v.Name).PlayerGui:FindFirstChild("LeaveBus") wait() game.Players:FindFirstChild(v.Name).PlayerGui:FindFirstChild("LeaveBus"):Destroy() game.ServerStorage.Camera:Clone().Parent = game.Players:FindFirstChild(v.Name).PlayerGui end end local model = game:GetService("Workspace"):FindFirstChild("Bus", true) local rightSpeed = 0 local upSpeed = 0 local forwardSpeed = -2.5 wait() if (model ~= nil) then local oldprimarypart = model.PrimaryPart model.PrimaryPart = model.PrimaryPart for i = 0, 288 do wait() model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.new(rightSpeed, upSpeed, forwardSpeed)) end end end wait(1) end --[[Script 2 (Script inside a part of the bus, when they touch this part it sets the parent of the character.)]] local brick = script.Parent local debounce = false function onTouch(part) repeat wait() until part.Parent:FindFirstChild("Humanoid") repeat wait() until part.Parent:FindFirstChild("HumanoidRootPart") if not debounce then debounce = true local player = game.Players:GetPlayerFromCharacter(part.Parent) repeat wait() until part.Parent local human = part.Parent:FindFirstChild("Humanoid") local rootPart = part.Parent:FindFirstChild("HumanoidRootPart") local availableSpawnPoints1 = workspace.AvailableSpawns1:GetChildren() repeat wait() until human human.WalkSpeed = 0 human.JumpPower = 0 wait() rootPart.CFrame = availableSpawnPoints1[math.random(1, #availableSpawnPoints1)].CFrame + Vector3.new(0, 1, 0) table.remove(availableSpawnPoints1, 1) repeat wait() until player.Character.Parent player.Character.Parent = workspace.Bus game.ServerStorage.LeaveBus:Clone().Parent = player.PlayerGui wait(.2) debounce = false end end brick.Touched:Connect(onTouch)
Try making a table and when you touch a part in the bus it changes a Value and when the value 5 then function(). Try using a debounce variable