#Detect a player when he jumped (Local Script)

1 messages · Page 1 of 1 (latest)

modern jay
#

I am doing a running system. But when my character jumps, the player stops running. That's why I try to detect how do I detect when the player is running, and if so, the player continues running. I tried to look at some forums but I didn't understand a thing. Can someone help me ?

#
local UIS = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local event = game.ReplicatedStorage:WaitForChild("SprintEvent")
local tweens = game:GetService("TweenService")
local zoomOut = tweens:Create(camera, TweenInfo.new(0.5, Enum.EasingStyle.Back), {FieldOfView = 90})
local zoomIn = tweens:Create(camera, TweenInfo.new(0.5, Enum.EasingStyle.Back), {FieldOfView = 70})
local isOn = false
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
local char = plr.Character

UIS.InputBegan:Connect(function(input, V)
    if V then return end
    
    if input.keyCode == Enum.KeyCode.LeftShift then
        isOn = not isOn
        if isOn then
        zoomOut:Play()
        event:FireServer("sprint")
    else
        zoomIn:Play()
        event:FireServer("walk")
        end
    end
end)
keen slate
#

You might have to use humanoid.Running function

modern jay
#

why ?

#

I need to detect if the character is jumping not running ?

keen slate
#

Well, you want to detect the WalkSpeed right?

#

Oh nvm

#

Then it's humanoid.Jumping i assume

modern jay
#

where?

#

I need to make a new function for that ?

modern jay
#

I'm reading it but it doesn't explain to me how can I use it

#

lemme try

keen slate
#

It's a function, like humanoid.Jumping:Connect(function()

end)

#

And then you would need to do what you want in this function

modern jay
#

but I need the humanoid

#

it doesn't wan

#

t

keen slate
#

Try WaitForChild

modern jay
#

Neither FindFirstChild nor WaitForChild work

keen slate
#

Maybe local char = plr.Character or plr.CharacterAdded:Wait()

modern jay
#

It's telling attemp to index with nil it means that it's not detecting the plr

#

ok it is working