In order to crouch, you will not change the Torso.Position
, but rather the legs position and location.
The easiest way to do this will be to create an animation. You also could do this with scripts, but it seems to be a waste of time when using an animation would be faster.
In order to learn how to create an animation, you should go to this roblox wiki page:
http://wiki.roblox.com/index.php?title=Animations
When making your animation, make sure it is a looping animation
After you have your crouch/prone animation finished, you should use this line of code in a LocalScript
inside StarterGui
:
02 | local CrouchanimationID = 0 |
03 | local ProneanimationID = 0 |
05 | game:GetService( "UserInputService" ).InputBegan:connect( function (inputObject, gameProcessedEvent) |
06 | if inputObject.KeyCode = = Enum.KeyCode.C then |
08 | setvalue = setvalue + 1 |
16 | local cranimation = game.Players.LocalPlayer.Character:WaitForChild( "Humanoid" ):LoadAnimation(CrouchanimationID) |
17 | local pranimation = game.Players.LocalPlayer.Character:WaitForChild( "Humanoid" ):LoadAnimation(ProneanimationID) |
20 | elseif setvalue = = 2 then |
If this code does NOT work, please pm me on ROBLOX.
https://www.roblox.com/messages/compose?recipientId=18982229
This will Not work with a FilteringEnabled game!
If you need the script to be FilteringEnabled, pm me!
~ Taryo