-- Services
local Players = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")
-- Player and Character References
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Target Waypoint Positions (replace these with your desired coordinates)
local teleportPosition = Vector3.new(-201.10, 15.54, -397.42) -- First waypoint for teleport
local walkPosition = Vector3.new(-238.26, 15.54, -410.37) -- Second waypoint for walking
-- Function to teleport the player to a specific position
local function teleportToPosition(position)
humanoidRootPart.CFrame = CFrame.new(position)
print("Teleported to: ", position)
end
-- Function to make the player walk to a specific position
local function walkToPosition(targetPosition)
-- Create a new path
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 10,
AgentMaxSlope = 45,
AgentCanClimb = false
})
-- Compute the path to the target position
path:ComputeAsync(humanoidRootPart.Position, targetPosition)
-- Check if the path status is complete
if path.Status == Enum.PathStatus.Complete then
local waypoints = path:GetWaypoints()
-- Walk to each waypoint
for _, waypoint in ipairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
-- Jump if needed
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
end
print("Reached destination: ", targetPosition)
else
warn("Path not found to the destination.")
end
end
-- Teleport to the first waypoint
teleportToPosition(teleportPosition)
-- Start walking to the second waypoint
walkToPosition(walkPosition)
To embed this project on your website, copy the following code and paste it into your website's HTML: