I have an NPC monkey. 2 parts, Head and Torso, R6 Humanoid. They are tasked to walk around to random points. However, when the monkeys reach a point that is 0.25 studs high, they cannot get over it without jumping. How do I allow them to walk up small steps like this?
If you’re using humanoid:MoveTo()
or humanoid:Move()
, then this would happen. I don’t think pathfind
has the same issue. Anyways, you can solve this through logic-
Try this code, it worked for me.
local function rtrnJump(obj)
if obj:IsA('BasePart') then
local objSize = obj.Size
if objSize.Y >= .25 then
return true
end
end
end
spawn(function()
while wait() do
for i, v in pairs(character:GetChildren()) do
if v:IsA('BasePart') then
v.Touched:Connect(function(hit)
if hit:IsA('BasePart') then
local shouldJump = rtrnJump(hit)
humanoid.Jump = shouldJump
else
--This part isn't really needed but if you have a model with only one child that is a base part, this will be useful.
local tb = hit:GetChildren()
if #tb > 1 then return
else
local shouldJump2 = rtrnJump(hit)
humanoid.Jump = shouldJump2
end
end
end)
end
end
end
end)
I already have an NPC script so this works for me. Put this inside the NPC (The model, not any of its children). If you do not want it to jump, you can toggle with the hip height of the NPC.
local function rtrnJump(obj)
if obj:IsA('BasePart') then
local objSize = obj.Size
if objSize.Y >= .25 then
return true
end
end
end
spawn(function()
while wait() do
for i, v in pairs(character:GetChildren()) do
if v:IsA('BasePart') then
v.Touched:Connect(function(hit)
if hit:IsA('BasePart') then
humanoid.HipHeight = 1 -- Toggle with this as it raises your humanoid height.
delay(1, function()
humanoid.HipHeight = 0 -- Set this to your original value.
end)
else
--This part isn't really needed but if you have a model with only one child that is a base part, this will be useful.
local tb = hit:GetChildren()
if #tb > 1 then return
else
humanoid.HipHeight = 1
delay(1, function()
humanoid.HipHeight = 0
end)
end
end
end)
end
end
end
end)
Hope this helps!
2 Likes