How do i delay NPC jump?

I want to make an npc jump one second after Jump was activated.
But it keeps jumping while Humanoid.Jump = true.
i tried doing

humanoid.Jumping:Connect(function()
	wait(1)
	humanoid.Jump = true
end)

but it keeps jumping in a loop.
i also tried

humanoid.Jumping:Wait(1)

but its not working. help?

1 Like

The .Jumping event means that the npc is already jumping. To achieve what you need, you’d have to modify the code of the npc.
For example, you might want to create a function called Jump, which would look something lile this:

function Jump(humanoid: Humanoid)
    task.delay(1, function()
        humanoid:Jump()
    end)
end

And you’d call that function instead of directly calling humanoid:Jump() in the code.

2 Likes

No that is not working. I guess that its a missing feature.

1 Like

@hannes213 Did a good job explaining the issue, but I’ll explain further to hopefully allow you to understand how it works.

The .Jumping event means that the npc is already jumping. To achieve what you need, you’d have to modify the code of the NPC.

Basically, if you use .Jumping that means that the NPC has already jumped, but using
function jump() will allow you to delay the jump,

function Jump()
   task.wait(1)
   humanoid.Jumping = true
end

After you have defined this function, call Jump() when you need the NPC to jump.
Example code:

local character = script.Parent -- Character (set to character you want)
local humanoid = character.Humanoid -- (The Character humanoid)

function Jump() -- Define Jump()
   task.wait(1) -- Wait 1 second
   humanoid.Jumping = true -- Set Jumping to true
end

Jump() -- call Jump() when you want the NPC to jump
1 Like

i thought about that but it works only the first time, in a loop that will make it jump immidiatly after the second turn, or it might pause the entire script if i do it with pathfinding server

could try something like this just set the attribute on the humanoid you could even change this to attribute on the npc model etc…

humanoid:GetAttributeChangedSignal('Jump'):Connect(function()
	if humanoid:GetAttribute('Jump') then
		humanoid:SetAttribute('Jump', nil)
		task.wait(1)
		humanoid.Jump = true
	end
end)

humanoid:SetAttribute('Jump', true)

should work with loops and you can tag it from any script thats on server or client depending on which you have the jump script on

So many tacky workaround, but i guess i will apply that for a while, hopefully roblox adds this feature

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.