local lastPosition = nil -- Track the player's last valid position local safeZoneRadius = 5 -- Radius of safe zone in studs local teleportResetTime = 0.5 -- Time in seconds to reset teleport count if safeZoneRadius<5 then safeZoneRadius=5 end -- Minimum safe zone radius local function teleportBack() local chr = game.Players.LocalPlayer.Character if chr and lastPosition then local humanoidRootPart = chr:FindFirstChild("HumanoidRootPart") if humanoidRootPart then humanoidRootPart.CFrame = CFrame.new(lastPosition) end end end game:GetService("RunService").Heartbeat:Connect(function() local chr = game.Players.LocalPlayer.Character if chr then local humanoidRootPart = chr:FindFirstChild("HumanoidRootPart") if humanoidRootPart then local currentPosition = humanoidRootPart.Position if not lastPosition then lastPosition = currentPosition return end local distance = (currentPosition - lastPosition).Magnitude if distance > safeZoneRadius then teleportBack() else lastPosition = currentPosition end end end end)