So basically, its a obby tutorial npc, when you click, it shows how to do that stage, but this does not work, no error is printed either, tell how to fix this please
Script:
local messages = {
"This is easy stage, follow me you can do it easily!",
"Look how I do this stage!",
"So this is how you do this stage!"
}
local pathfindingservice = game:GetService("PathfindingService")
local canworkfully = true
local npcuserid = game.Players:GetUserIdFromNameAsync("Deadwoodx")
local anim = game.ReplicatedStorage:WaitForChild("AnimationWalk"):Clone()
local anim2 = game.ReplicatedStorage:WaitForChild("AnimationRun"):Clone()
game.ReplicatedStorage.NPCTellEvent.OnClientEvent:Connect(function(number,part,stagenumber)
if canworkfully == true then
local success,errormessage = pcall(function()
canworkfully = false
print("Working")
local npc = game.Players:CreateHumanoidModelFromUserId(npcuserid)
npc.Parent = game.Workspace
wait(1)
game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame - Vector3.new(0,10,0)
npc.HumanoidRootPart.CFrame = part.Parent:WaitForChild("SpawnofNPC").CFrame + Vector3.new(0,5,0)
script.Parent.IsReplaying.Value = true
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Track
game.Workspace.CurrentCamera.CameraSubject = npc.Humanoid
local firstpath = pathfindingservice:CreatePath({
AgentRadius = 2,
AgentHeight = 16,
AgentCanJump = true,
WaypointSpacing = 5,
Costs = {
Killbrick = math.huge
}
})
firstpath:ComputeAsync(game.Workspace.Checkpoint:FindFirstChild(stagenumber).Position + Vector3.new(0,3,0),game.Workspace.Checkpoint:FindFirstChild(stagenumber + 1).Position + Vector3.new(0,3,0))
if firstpath.Status == Enum.PathStatus.Success then
for i,v in pairs(firstpath:GetWaypoints()) do
npc.Humanoid:MoveTo(v.Position)
if v.Action == Enum.PathWaypointAction.Jump then
npc.Humanoid.Jump = true
end
wait(1)
end
wait(1)
npc:Destroy()
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
else
local secondpath = pathfindingservice:CreatePath({
AgentRadius = 2,
AgentHeight = 16,
AgentCanJump = true,
WaypointSpacing = 5,
Costs = {
Killbrick = math.huge
}
})
for i = 1,number do
local path = pathfindingservice:CreatePath()
path:ComputeAsync(npc.HumanoidRootPart.Position,part.Parent:WaitForChild(i).Position)
local waypoints = path:GetWaypoints()
for i,v in pairs(waypoints) do
if v.Action == Enum.PathWaypointAction.Jump then
npc.Humanoid.Jump = true
npc.Humanoid:WaitForChild("Animator"):LoadAnimation(anim):Play()
else
npc.Humanoid:WaitForChild("Animator"):LoadAnimation(anim2):Play()
end
npc.Humanoid:MoveTo(v.Position)
npc.Humanoid.MoveToFinished:Wait(3)
end
end
end
game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored = false
canworkfully = true
script.Parent.IsReplaying.Value = false
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame + Vector3.new(0,10,0)
end)
if not success then
print(errormessage)
end
end
end)
It does not have any error, please check it