Ok here
local openedpos1 = UDim2.new(-0.5,0,0,0)
local closedpos1 = UDim2.new(0,0,0,0)
local openedpos2 = UDim2.new(1,0,0,0)
local closedpos2 = UDim2.new(0.5,0,0,0)
local pfs = game:GetService("PathfindingService")
local name = "Deadwoodx"
local userid = game.Players:GetUserIdFromNameAsync(name)
local plr = game.Players.LocalPlayer
local function findpath(checkpoint,npc)
local path = pfs:CreatePath({
Costs = {
Killbrick = math.huge
}
})
path:ComputeAsync(npc.HumanoidRootPart.Position,checkpoint.Position + Vector3.new(0,3,0))
local waypoints = path:GetWaypoints()
for i,v in pairs(waypoints) do
npc.Humanoid:MoveTo(v.Position)
npc.Humanoid.MoveToFinished:Wait(0.35)
end
task.wait(1)
script.Parent.Frame:TweenPosition(closedpos1,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.5)
script.Parent.Frame2:TweenPosition(closedpos2,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.5)
task.wait(0.5)
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
game.Workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid
npc:Destroy()
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
if v.Name ~= "TutorialGui" then
v.Enabled = true
end
end
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
v.Visible = false
end
end
script.Parent.Visible = false
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
end
local function climbladder(npc,ladderchosen,checkpoint)
local ladderbottompos = ladderchosen.Position - Vector3.new(0,(ladderchosen.Size.Y/2) - 2,0)
local path = pfs:CreatePath()
path:ComputeAsync(npc.HumanoidRootPart.Position,ladderbottompos + ladderchosen.CFrame.LookVector*-3)
print(path.Status)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
print(#waypoints)
for i,v in pairs(waypoints) do
print("moved")
npc.Humanoid:MoveTo(v.Position)
npc.Humanoid.MoveToFinished:Wait(1)
end
npc.Humanoid:MoveTo(ladderchosen.Position + Vector3.new(0,(ladderchosen.Size.Y/2) + 2,0))
npc.Humanoid.MoveToFinished:Connect(function()
task.wait(1)
findpath(checkpoint,npc)
end)
end
end
game.ReplicatedStorage.TutorialEvent.OnClientEvent:Connect(function(screenpart,folder)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
script.Parent.Visible = true
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
if v.Name ~= "TutorialGui" then
v.Enabled = false
end
end
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
v.Visible = true
end
end
local npc = game.Players:CreateHumanoidModelFromUserId(userid)
npc.Parent = workspace
for i,npcpart in pairs(npc:GetDescendants()) do
if npcpart:IsA("BasePart") then
npcpart.Anchored = false
end
end
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame += Vector3.new(0,150,0)
-- game.Players.LocalPlayer.Character["Left Leg"].Anchored = true
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Follow
game.Workspace.CurrentCamera.CameraSubject = npc.Humanoid
npc.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
script.Parent.Frame:TweenPosition(openedpos1,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.5)
script.Parent.Frame2:TweenPosition(openedpos2,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.5)
local currentcheckpoint = game.Workspace.Checkpoint:FindFirstChild(script.Parent.Parent.Parent.StageDisplayGui.Frame.TextBox.Text)
npc:WaitForChild("HumanoidRootPart").CFrame = currentcheckpoint.CFrame + Vector3.new(0,3,0)
local path = pfs:CreatePath({
Costs = {
Killbrick = math.huge
}
})
local currentwaypoint = 0
path:ComputeAsync(npc.HumanoidRootPart.Position,game.Workspace.Checkpoint:FindFirstChild(tonumber(currentcheckpoint.Name) + 1).Position + Vector3.new(0,3,0))
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for i,v in pairs(waypoints) do
if v.Action == Enum.PathWaypointAction.Jump then
npc.Humanoid.Jump = true
end
npc.Humanoid:MoveTo(v.Position)
currentcheckpoint = i
npc.Humanoid.MoveToFinished:Wait(1)
end
task.wait(1)
script.Parent.Frame:TweenPosition(closedpos1,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.5)
script.Parent.Frame2:TweenPosition(closedpos2,Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.5)
task.wait(0.5)
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
game.Workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid
npc:Destroy()
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
if v.Name ~= "TutorialGui" then
v.Enabled = true
end
end
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
v.Visible = false
end
end
script.Parent.Visible = false
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
else
local ladders = folder:GetChildren()
local chosenladder = nil
for i,ladder in pairs(ladders) do
local path = pfs:CreatePath({
Costs = {
Killbrick = math.huge
}
})
path:ComputeAsync(ladder.Position + Vector3.new(0,((ladder.Size.Y/2) + 1),0),game.Workspace.Checkpoint:FindFirstChild(tonumber(currentcheckpoint.Name) + 1).Position)
if path.Status == Enum.PathStatus.Success then
chosenladder = ladder
end
end
if chosenladder ~= nil then
climbladder(npc,chosenladder,game.Workspace.Checkpoint:FindFirstChild(tonumber(currentcheckpoint.Name) + 1))
end
end
end)