I’m trying to make a functioning npc that chases you whenever you’re in their “LoS” radius.
It was going quite flawlessly until I decided to check whether the fella can jump or not, turns out his legs are a bit broken.
He does walk towards you, but he just doesn’t have the ability to jump, for some reason.
This is what happens (compressed because went above file size!!)
I don’t see any issues with my code:
local LOSsize = Vector3.new(75,25,75)
local Dummy = script.Parent
local PF = game:GetService("PathfindingService")
local DummyHumanoid = Dummy.HumanoidRootPart
local RS = game:GetService("RunService")
local players = game:GetService("Players")
function createAreapreview()
local part = Instance.new("Part")
part.Name = "LoSChecker"
part.Parent = Dummy.HumanoidRootPart
part.CFrame = Dummy.HumanoidRootPart.CFrame
part.Size = LOSsize
part.Color = Color3.fromRGB(255, 0, 4)
part.Anchored = true
part.Transparency = 0.6
part.CanCollide = false
end
createAreapreview()
local DMGsize = Vector3.new(10,7,10)
function createDamageArea() -- ignore this function, it's irrelevant to the issue
local part = Instance.new("Part")
part.Name = "DamageDealer"
part.Parent = Dummy.HumanoidRootPart
part.CFrame = Dummy.HumanoidRootPart.CFrame
part.Size = DMGsize
part.Color = Color3.fromRGB(230, 255, 120)
part.Anchored = true
part.Transparency = 0.6
part.CanCollide = false
end
createDamageArea()
local dmgDealer = DummyHumanoid.DamageDealer -- ignore this also
local losChecker = DummyHumanoid.LoSChecker
local parameterTable = {
AgentRadius = 3,
AgentHeight = 5,
AgentCanJump = true, -- set to true but the guy still doesn't jump
AgentCanClimb = false,
WaypointSpacing = 2
}
RS.Stepped:Connect(function()
---------------LINE OF SIGHT CHECKER----------------
local LOS = workspace:GetPartBoundsInBox(losChecker.CFrame, losChecker.Size)
losChecker.CFrame = DummyHumanoid.CFrame
for _,v in LOS do
if v.Parent:FindFirstChild("Humanoid") then
local plr = players:GetPlayerFromCharacter(v.Parent)
if plr then
losChecker.Color = Color3.fromRGB(123, 255, 93)
local path = PF:CreatePath(parameterTable)
path:ComputeAsync(DummyHumanoid.Position, plr.Character.HumanoidRootPart.Position)
if path.Status == Enum.PathStatus.Success then
Dummy.Humanoid:MoveTo(plr.Character.HumanoidRootPart.Position)
end
else
losChecker.Color = Color3.fromRGB(255, 0, 4)
end
end
end
-- there's more code under here but it's connected to the damage function, no "ends" are missing
```