ADVERTISEMENTREMOVE ADS
Stage Auto Teleporter Open Sourced
47,179 views
Script Preview
Description
The script automates teleporting the player's character to multiple stages in the game to trigger their "TouchInterest" events. It disables collision on stages to prevent obstruction, teleports the character to each stage's trigger part, waits briefly to register the touch, then moves on. It processes stages both in the workspace’s "Checkpoints" folder and directly under workspace by numbered names. After processing, it returns the character to the original position and restores collisions and character control. It handles errors by resetting collisions and position safely.
Features:
- Locate
- Disable
- Teleport
- Trigger
- Restore
Tested with
ADVERTISEMENTREMOVE ADS
299 Lines • 8.21 KiB
Verified
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local workspace = game:GetService("Workspace")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local STAGE_PREFIX = ""
local MAX_STAGES = 1000
local TELEPORT_DELAY = 0
local TELEPORT_OFFSET = Vector3.new(0, 5, 0)
local USE_SMOOTH_TELEPORT = false
local originalPosition = humanoidRootPart.CFrame
local originalCollisionStates = {}
local function disableCollision(part)
if part:IsA("BasePart") then
originalCollisionStates[part] = part.CanCollide
part.CanCollide = false
end
for _, child in pairs(part:GetChildren()) do
disableCollision(child)
end
end
local function restoreCollision(part)
if part:IsA("BasePart") and originalCollisionStates[part] ~= nil then
part.CanCollide = originalCollisionStates[part]
originalCollisionStates[part] = nil
end
for _, child in pairs(part:GetChildren()) do
restoreCollision(child)
end
end
local function findTouchInterestAndPosition(obj)
local function searchForTouchInterest(o)
local touchInterest = o:FindFirstChild("TouchInterest")
if touchInterest and o:IsA("BasePart") then
return o, touchInterest
end
for _, child in pairs(o:GetChildren()) do
local foundPart, foundTouchInterest = searchForTouchInterest(child)
if foundPart and foundTouchInterest then
return foundPart, foundTouchInterest
end
end
return nil, nil
end
local touchPart, touchInterest = searchForTouchInterest(obj)
if touchPart then
local partPosition = touchPart.Position
local partSize = touchPart.Size
local teleportPosition = partPosition + TELEPORT_OFFSET + Vector3.new(0, partSize.Y/2, 0)
return touchPart, touchInterest, CFrame.new(teleportPosition)
end
return nil, nil, nil
end
local function instantTeleport(targetCFrame)
if not character or not character.Parent then
return false
end
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then
return false
end
humanoidRootPart.CFrame = targetCFrame
return true
end
local function smoothTeleport(targetCFrame, duration)
if not character or not character.Parent then
return false
end
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then
return false
end
duration = duration or 0.5
local tweenInfo = TweenInfo.new(
duration,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
false,
0
)
local tween = TweenService:Create(humanoidRootPart, tweenInfo, {CFrame = targetCFrame})
tween:Play()
tween.Completed:Wait()
return true
end
local function freezeCharacter()
if humanoid then
humanoid.PlatformStand = true
humanoid.Sit = false
humanoid.Jump = false
end
end
local function unfreezeCharacter()
if humanoid then
humanoid.PlatformStand = false
end
end
local function waitForTouch(touchPart, timeout)
timeout = timeout or 1
local startTime = tick()
local touched = false
local connection
connection = touchPart.Touched:Connect(function(hit)
if hit.Parent == character then
touched = true
connection:Disconnect()
end
end)
while not touched and (tick() - startTime) < timeout do
wait(0.1)
end
connection:Disconnect()
return touched
end
local function findStage(stageNumber)
local stageName = STAGE_PREFIX .. tostring(stageNumber)
if workspace:FindFirstChild("Stages") then
return workspace.Stages:FindFirstChild(stageName)
end
return nil
end
local function findWorkspaceStage(stageNumber)
return workspace:FindFirstChild(tostring(stageNumber))
end
local function findCheckpoint(checkpointNumber)
if workspace:FindFirstChild("Checkpoints") then
return workspace.Checkpoints:FindFirstChild(tostring(checkpointNumber))
end
return nil
end
local function processSingleStage(stage, stageNumber, stageType)
disableCollision(stage)
local touchPart, touchInterest, teleportCFrame = findTouchInterestAndPosition(stage)
if touchPart and touchInterest and teleportCFrame then
local teleportSuccess
if USE_SMOOTH_TELEPORT then
teleportSuccess = smoothTeleport(teleportCFrame, 0.3)
else
teleportSuccess = instantTeleport(teleportCFrame)
end
if teleportSuccess then
wait(TELEPORT_DELAY)
waitForTouch(touchPart, 0.5)
return true
else
return false
end
else
return false
end
restoreCollision(stage)
end
local function processSingleCheckpoint(checkpoint, checkpointNumber)
disableCollision(checkpoint)
local touchPart, touchInterest, teleportCFrame = findTouchInterestAndPosition(checkpoint)
if touchPart and touchInterest and teleportCFrame then
local teleportSuccess
if USE_SMOOTH_TELEPORT then
teleportSuccess = smoothTeleport(teleportCFrame, 0.3)
else
teleportSuccess = instantTeleport(teleportCFrame)
end
if teleportSuccess then
wait(TELEPORT_DELAY)
waitForTouch(touchPart, 0.5)
return true
else
return false
end
else
return false
end
restoreCollision(checkpoint)
end
local function processAllStagesAndCheckpoints()
freezeCharacter()
local processedStages = 0
local failedStages = 0
if workspace:FindFirstChild("Stages") then
for stageNumber = 1, MAX_STAGES do
local stage = findStage(stageNumber)
if not stage then break end
local success = processSingleStage(stage, stageNumber, "Stage")
if success then
processedStages = processedStages + 1
else
failedStages = failedStages + 1
end
restoreCollision(stage)
wait(0.1)
end
end
for stageNumber = 1, MAX_STAGES do
local stage = findWorkspaceStage(stageNumber)
if not stage then break end
local success = processSingleStage(stage, stageNumber, "Workspace Stage")
if success then
processedStages = processedStages + 1
else
failedStages = failedStages + 1
end
restoreCollision(stage)
wait(0.1)
end
if workspace:FindFirstChild("Checkpoints") then
for checkpointNumber = 1, MAX_STAGES do
local checkpoint = findCheckpoint(checkpointNumber)
if not checkpoint then break end
local success = processSingleCheckpoint(checkpoint, checkpointNumber)
if success then
processedStages = processedStages + 1
else
failedStages = failedStages + 1
end
restoreCollision(checkpoint)
wait(0.1)
end
end
if USE_SMOOTH_TELEPORT then
smoothTeleport(originalPosition, 0.5)
else
instantTeleport(originalPosition)
end
unfreezeCharacter()
end
local function safeProcessAll()
local success, error = pcall(processAllStagesAndCheckpoints)
if not success then
for part, originalState in pairs(originalCollisionStates) do
if part and part.Parent then
part.CanCollide = originalState
end
end
if humanoidRootPart and humanoidRootPart.Parent then
humanoidRootPart.CFrame = originalPosition
end
unfreezeCharacter()
end
end
safeProcessAll()
ADVERTISEMENTREMOVE ADS
ADVERTISEMENTREMOVE ADS






Comments