Is there a better way to check if a person is running or not?

Hi there!

I hope you’re well.

I’m working on a VFX script. My goal is to try to make the script detect when the person is running and when it isn’t, so if the person is running, it can emit particles, and when they’re not running, it doesn’t emit particles.

So what’s my problem??

My current script… is not very reliable. It doesn’t always work. If a person jumps, the effects don’t stop. I’ve tried using FloorMaterial, :GetState() method, and so on, to no avail. If anything, it made things worse so, I reverted the script.

What can I do to fix this? Thanks!

local function onRunning(speed)
        if speed > 0 then
            print("Person is running")
            if isRunning == true then
                return
            else
                isRunning = true
                Event:Fire("Run", isRunning)
            end
        else if speed == 0 then
                print("Person stopped or in air")
                print(speed)
                isRunning = false
                Event:Fire("Idle", isRunning)
            end
        end
end

humanoid.Running:Connect(onRunning)

This is part of the script in charge of detecting when a person is running or vice versa. What can I do to stabilize this script?

Here’s a video of it

Thanks!
Aki

3 Likes

Make a local Particles on = true

1 Like

Use enum.keycode.spacebar also your pc is very very very laggy

1 Like

How will this help if you don’t mind me asking?

1 Like

Im just walking through the steps mentaly

2 Likes

It’s not my PC that’s laggy heh, it’s the footage. It’s using a lot of resources since I’m on studio. Also, do you think that UIS would be helpful and efficient in this case? because the person could be falling and still have particles. So I don’t think it’s the most efficient.

1 Like

Im making a function that will blow when a player jumps then making a veritable change stoping the particles

1 Like

Uhh alright, sure thanks! Though, what about the falling action? Should I also make a separate function for that?

1 Like

I would make it so when the players feet toutch the ground it turns the verryable on

1 Like

Im relatively new to scripting and still learning so idk what that is

1 Like

I’d assuming using Floor Material or humanoid.Landed?

1 Like

It’s basically what you’ve mentioned but the action is falling instead of jumping.

1 Like

Yes (charrachtor limmit dont mind it)

1 Like

Well goodluck ( dont mind thissss)

1 Like

Though I’ve already tried FloorMaterial as I mentioned. It didn’t work out very well. Also, isn’t there a more efficient way so I don’t have to make different functions for the same purpose, just different conditions?

1 Like

I ssuuppoosseeeeeeeeeeeeeeeeeeee

1 Like

I can get to my computer to try diffrent smh

1 Like

Check the humanoid’s movedirection magnitude.

For example:

if humanoid.MoveDirection.Magnitude > 0 then
    --the player is running
end
5 Likes


Something like this?

1 Like

You could just do an else statement but that’s the gist of it.

1 Like