As the titles says Im trying to make it so the player becomes anchored after they land from a jump. Instead the script only has a jump cooldown and does not anchor, I don't know where I went wrong. Here is my failed attempt.
01 | local character = script.Parent |
02 |
03 | local JUMP_DEBOUNCE = 5 |
04 |
05 | local root = character:WaitForChild( "HumanoidRootPart" ) |
06 | local humanoid = character:WaitForChild( "Humanoid" ) |
07 |
08 | local isJumping = root.Anchored |
09 |
10 | humanoid.StateChanged:Connect( function (oldState, newState) |
11 | if newState = = Enum.HumanoidStateType.Jumping then |
12 | if not isJumping then |
13 | isJumping = true |
14 | humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false ) |
15 | end |
You did a simple mistake. You must anchor it after it lands not when it jumps Here is the script that worked for me
01 | local character = script.Parent |
02 |
03 | local JUMP_DEBOUNCE = 5 |
04 |
05 | local root = character:WaitForChild( "HumanoidRootPart" ) |
06 | local humanoid = character:WaitForChild( "Humanoid" ) |
07 |
08 | local isJumping = root.Anchored |
09 |
10 | humanoid.StateChanged:Connect( function (oldState, newState) |
11 | if newState = = Enum.HumanoidStateType.Jumping then |
12 | if isJumping then |
13 | root.Anchored = false |
14 | end |
15 | elseif newState = = Enum.HumanoidStateType.Landed then |
When you anchor the root part you cannot walk, jump, and run. It's like platformstand.