I have no idea what category do i put it in sorry
I wanted to make an npc that “carries” the player,i tried using weld to do that but it makes the npc unable to move and after i disable the weld it starts moving but glitchy.
Please help i think i’ve done everything i could have.
Explorer model screenshot
AI script
local PathFindingService = game:GetService("PathfindingService")
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Target = workspace.Waypoints.Sweep["10"]
local retryamount = 1
local function ComputePath(startpoint,endpoint)
local Path = PathFindingService:CreatePath()
Path:ComputeAsync(startpoint,endpoint)
if Path.Status == Enum.PathStatus.Success then
return Path
else
warn("Unsuccessful path")
if retryamount < 3 then
ComputePath()
retryamount += 1
warn("Retrying")
else
warn("Bruh")
end
end
end
local function Walk(humanoid,startpoint,endpoint)
local Path = ComputePath(startpoint,endpoint)
local Waypoints = Path:GetWaypoints()
local CurrentWaypointIndex = 2
MoveToFinishedConnect = Humanoid.MoveToFinished:Connect(function(reached)
if reached then
if CurrentWaypointIndex < #Waypoints then
CurrentWaypointIndex += 1
Humanoid:MoveTo(Waypoints[CurrentWaypointIndex].Position)
else
print("Finish Line!")
MoveToFinishedConnect:Disconnect()
end
else
-- if didnt reach
MoveToFinishedConnect:Disconnect()
Walk(humanoid,startpoint,endpoint)
end
end)
humanoid:MoveTo(Waypoints[CurrentWaypointIndex].Position)
end
Walk(Humanoid,script.Parent.HumanoidRootPart.Position,Target.Position)
Script in the “Hitbox” part
local Sweep = script.Parent
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false)
local SweepWaypoints = workspace.Waypoints.Sweep
local SweepWaypointTable = {}
SweepWaypointTable = SweepWaypoints:GetChildren()
print(SweepWaypointTable[math.random(1,#SweepWaypoints:GetChildren())])
local goals1 = {}
Sweep.Touched:Connect(function(hit)
if game.Players:FindFirstChild(hit.Parent.Name) or hit.Parent:FindFirstChild("IsACharacter") then
if hit.Parent:FindFirstChild("SweepWeld") then
else
hit.Parent.Humanoid.WalkSpeed = 0
local SweepWeldChr = Instance.new("Weld")
SweepWeldChr.Name = "SweepWeld"
SweepWeldChr.Parent = hit.Parent
SweepWeldChr.Part1 = hit.Parent.HumanoidRootPart
SweepWeldChr.Part0 = Sweep
local JankyEvent = hit.Parent.Torso.Changed:Connect(function()
hit.Parent.Torso.CanCollide = false
end)
task.wait(math.random(999,9999))
JankyEvent:Disconnect()
SweepWeldChr.Part0 = nil
hit.Parent.Humanoid.WalkSpeed = 25
task.wait(5)
SweepWeldChr:Destroy()
end
end
end)
please help
Thanks in advance.