Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to detect humanoid jumping?

local character = script.Parent 
local humanoid = character:WaitForChild("Humanoid")
humanoid.Jumping:Connect(function(isActive)
	print("Jumping: ", isActive)
end)

The script is from Roblox wiki and script below is what I used it to detect player jumping.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteStorage = ReplicatedStorage:WaitForChild("RemoteEvents")
local Remote = RemoteStorage:WaitForChild("ForwardDashEvent")

local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = Char:WaitForChild("Humanoid")

local userinput = game:GetService("UserInputService")

-- Settings --
local Debounce = true
local pressed = tick()
local waitTime= .25

local Anim = Instance.new("Animation")
Anim.AnimationId = 'rbxassetid://2589911948'

humanoid.Jumping:Conncet(function(isActive)

userinput.InputBegan:connect(function(Input, IsTyping)
	if IsTyping then return end
if isActive then return end
	if Input.KeyCode == Enum.KeyCode.W and Debounce then
       if tick() - pressed < waitTime and Debounce then
	Remote:FireServer()
		Debounce = false
		local LoadAnimation = Char.Humanoid:LoadAnimation(Anim)
		LoadAnimation:Play()
		humanoid.AutoRotate = false
		wait(.5)
		LoadAnimation:Stop()
		humanoid.AutoRotate = true
		wait(.5)
		Debounce = true
        else
		end
        pressed = tick()
		end
	end)
end)

So I have a dashing feature in my game. And I want to make players not able to dash while player is jumping. however, disable won't work and you are able to dash even tough you did not landed yet. How do I fix this problem?

if isActive then return end is what I used to disable players dashing while jumping.

1 answer

✓ Accepted answer

Easy, there is a jump property in the humanoid, it is a bool value, use the changed function:

local humanoid = script.Parent.Humanoid -- define

humanoid.Jump.Changed:Connect(function()
	print("Jumped")
end)

If this helps, click answer please otherwise in comments ask if it isn't working or if you need help.

3 comments

0

Thanks :)

0

humanoid.Jump.Changed but jump's a property? :thinking:

0

Jump Is a bool value in a property m8 ^

This discussion is preserved as it was. New answers, comments, and votes are closed.