Custom Crawling System

I made a custom crawling system but I need help in that the player can’t get up in specific places or in small places
so i tried script the next parts


There are 3 parts
Red Part: to detect a player touching it and DISABLE a boolean called “CanJump” that can enable if the player can jump or not
There’s the RED part script:

script.Parent.Touched:Connect(function(hit)
      if game.Players:FindFirstChild(hit.Parent.Name) and game.Players:FindFirstChild(hit.Parent.Name):FindFirstChild("CanJump") and game.Players:FindFirstChild(hit.Parent.Name):WaitForChild("CanJump").Value == true then --Detect the player and the boolean "CanJump"
            local plr = game.Players:FindFirstChild(hit.Parent.Name)
            plr:WaitForChild("CanJump").Value = false --Disable the boolean
      end
end)

Blue Parts: to detect a player touching it and ENABLE the boolean “CanJump” that can enable if the player can jump or not
There’s the BLUE parts script:

script.Parent.Touched:Connect(function(hit)
       if game.Players:FindFirstChild(hit.Parent.Name) and game.Players:FindFirstChild(hit.Parent.Name):FindFirstChild("CanJump") and game.Players:FindFirstChild(hit.Parent.Name):WaitForChild("CanJump").Value == false then --Detect the player and the boolean "CanJump"
             local plr = game.Players:FindFirstChild(hit.Parent.Name)
             plr:WaitForChild("CanJump").Value = true --Enable the boolean "CanJump"
       end
end)

It’s working but it has errors

You can probably just raycast above the player and if it hits something in a short distance, dont allow them to stand up, if the raycast is higher/normal, then allow them to stand up.

6 Likes

understood, but can you explain me more about this?

Raycast above the character using the normal raycast direction or just Vector3.new(0, 5, 0).

If the raycast hits, check, is it close to the charcter? You can do this by getting the position of the raycast hit and the position of the rootpart of the character. Compare them however you decide on the y axis or magnitude if you even wanted to.

If it reaches a certain number, then stay crouched until further notice, else, uncrouch.