note: the script above the walk script is the death effect
Code:
local waypoints = workspace.WaypOints
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = char:FindFirstChild("Humanoid")
if char ~= nil then
for waypoint = 1, #waypoints:GetChildren() do
humanoid:MoveTo(waypoints:WaitForChild(waypoint).Position)
humanoid.MoveToFinished:Wait()
end
else
return
end
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local WayPoints = workspace:FindFirstChild("WaypOints") -- I think you might've misspelt WayPoints?
local function moveToWaypoints(humanoid: Humanoid)
for _, waypoint in pairs(WayPoints:GetChildren()) do
if humanoid then
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
else
return
end
end
end
local function handleWaypoints()
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local humanoid = Character:FindFirstChild("Humanoid"):: Humanoid
if humanoid then
moveToWaypoints(humanoid)
end
end
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid"):: Humanoid
humanoid.Died:Connect(function()
handleWaypoints()
end)
end
LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
handleWaypoints()
I might’ve just written it wrong then since I was rushing, take your original code and just make it run with a Humanoid.Died event so it’ll run again or connect it to a CharacterAdded event. The latter is probably better.
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local WayPoints = workspace:FindFirstChild("WaypOints") -- I think you might've misspelt WayPoints?
local function moveToWaypoints(humanoid: Humanoid)
for waypoint = 1, #WayPoints:GetChildren() do
if humanoid then
humanoid:MoveTo(WayPoints:FindFirstChild(waypoint).Position)
humanoid.MoveToFinished:Wait()
else
return
end
end
end
local function handleWaypoints()
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local humanoid = Character:FindFirstChild("Humanoid"):: Humanoid
if humanoid then
moveToWaypoints(humanoid)
end
end
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid"):: Humanoid
humanoid.Died:Connect(function()
handleWaypoints()
end)
end
LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
handleWaypoints()