And it seems like the functions should work in turn, but in fact they do not work the way I intended. If you put one at a time, then everything works.
wait(3)
local PathfindingService = game:GetService("PathfindingService")
local Humanoid = script.Parent.Humanoid
local Root = script.Parent:FindFirstChild("HumanoidRootPart")
-- Dress
local DressRooms = game.Workspace.DressRooms
local RandomDressRoom = DressRooms:GetChildren()[math.random(1, #DressRooms:GetChildren())]
local Dressgoal1 = RandomDressRoom.Goal1.Position
local Dressgoal2 = RandomDressRoom.Goal2.Position
local Dressgoal3 = RandomDressRoom.Goal3.Position
-- Dress
-- Weight
local Weigts = game.Workspace.WeigtRacks
local RandomWeight = Weigts:GetChildren()[math.random(1, #Weigts:GetChildren())]
local WeithtGoal1 = RandomWeight.Goal1.Position
local WeithtGoal2 = RandomWeight.Goal2.Position
-- Weights
local function moveToGoal(goal)
local path = PathfindingService:CreatePath()
path:ComputeAsync(Root.Position, goal)
local waypoints = path:GetWaypoints()
for i, waypoint in ipairs(waypoints) do
Humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid.MoveToFinished:Wait()
end
end
moveToGoal(WeithtGoal1)
local function dressing()
moveToGoal(Dressgoal1)
task.wait(0.75)
moveToGoal(Dressgoal2)
task.wait(6)
moveToGoal(Dressgoal3)
end
local function Weight()
moveToGoal(WeithtGoal1)
task.wait(15)
moveToGoal(WeithtGoal2)
end
dressing()
Humanoid.MoveToFinished:Wait()
Weight()
script located in npc