I want to make a crouch/prone script, but do any of you know how to lower the torso?
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
:
local setvalue = 0 local CrouchanimationID = 0 -- Crouch Animation ID local ProneanimationID = 0 -- Prone Animation ID game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.C then if setvalue < 2 then setvalue = setvalue + 1 else setvalue = 0 end end end) while wait() do local cranimation = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(CrouchanimationID) local pranimation = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(ProneanimationID) if setvalue==1 then cranimation:Play() elseif setvalue==2 then pranimation:Play() end wait(0.5) --[[ Make the wait as long as your animation will be played until it loops. ]] end
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