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
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)
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.