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

How do I check if the character is not climbing? [CLOSED]

Asked by 5 years ago
Edited 5 years ago

ive made a script with a climbing animation but i dont know when im not climbing heres the script

character.Humanoid.Climbing:connect(function()
climbing = true
end)

this activates if climbing but i dont know how to disable it if im not climbing

thanks

0
THANKS ALOT BOTH OF THE ANSWERS WORK fortune80 -4 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

What you are looking for is Humanoid.StateChanged, just like the name states, it fires whenever a humanoid state changes. It's listeners have 2 parameters: old and new. You can check it out here.

So you basically check if old is climbing:

Humanoid.StateChanged:Connect(function(old, new)
    if old == Enum.HumanoidStateType.Climbing then
        climbing = false -- not climbing anymore
    end
end)
Ad
Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Well, you can use the Humanoid.StateChanged to see if a player is climbing or if they are not!

https://developer.roblox.com/api-reference/event/Humanoid/StateChanged

Here is a script that showcases Humanoid.StateChanged, taken from that wiki page (make sure this is a local script in the StarterPlayerScripts)

local JUMP_DEBOUNCE = 1
local isJumping = false
humanoid.StateChanged:Connect(function(oldState, newState)
    if newState == Enum.HumanoidStateType.Jumping then
        if not isJumping then
            isJumping = true
            humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        end
    elseif newState == Enum.HumanoidStateType.Landed then
        if isJumping then
            isJumping = false
            wait(JUMP_DEBOUNCE)
            humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
        end
    end
end)

If this helped, please upvote, and if it didn't work, please comment.

Answer this question