Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to make a script that change a value when you jump ?

Asked by 5 years ago

I want a script that when you jump you lose stamina. I try to search with the space key but that dont work....

1 answer

Log in to vote
1
Answered by 5 years ago

You can use either Jumping or StateChanged. They are both events of a Humanoid that can be used to tell when a Humanoid is jumping. Because they are events, you would connect them to functions, like so:

Using Jumping:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character.Humanoid.Jumping:Connect(function()
            -- Code here
        end)
    end)
end)

Using StateChanged, which fires with two arguments, the original state and the new state of the Humanoid:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character.Humanoid.StateChanged:Connect(function(originalState, newState)
            -- Code here
        end)
    end)
end)

By using the code given, you can expand upon what I gave you as examples to accomplish what you're looking to do.

0
Also, one other thing: You don't necessarily need user input. Jumping takes care of that for you. DeceptiveCaster 3761 — 5y
0
THHHXXX!!!!! scorpion981 27 — 5y
0
accept the answer Arkrei 389 — 5y
Ad

Answer this question