So this localscript inside of startercharacterscripts is meant to resize the character's HumanoidRootPart and make it really short on the Y scale, which is supposed to act kind of like a crouch.
1 | local Player = game.Players.LocalPlayer |
2 | local Character = Player.Character |
3 | local CharAnimation |
4 | local hrp = Character;FindFirstChild( "HumanoidRootPart" ) |
5 | game:GetService( "UserInputService" ).InputBegan:Connect( function (inputObject, gameProcessedEvent) |
6 | if inputObject.KeyCode = = Enum.KeyCode.C then |
7 | hrp.Size = Vector 3. new(script.Parent.Size.X,script.Parent.Size.Y - 1.9 ,script.Parent.Size.Z) |
So basically, it's supposed to resize the HumanoidRootPart when the player presses "C", but it deosn't do that. please help
Before you start, make a RemoteEvent in ReplicatedStorage called "Crouch"
This is the localscript that is located in StarterPlayerScripts:
01 | local player = game.Players.LocalPlayer |
02 | local uis = game:GetService( "UserInputService" ) |
03 | local rp = game:GetService( "ReplicatedStorage" ) |
04 | local crouchevent = rp:WaitForChild( "Crouch" ) |
05 |
06 | uis.InputBegan:connect( function (input) |
07 | if input.KeyCode = = Enum.KeyCode.C then |
08 | crouchevent:FireServer() |
09 | end |
10 |
11 | end ) |
This is the script thats located in ServerScriptService:
01 | local rp = game:GetService( "ReplicatedStorage" ) |
02 | local crouchevent = rp:WaitForChild( "Crouch" ) |
03 |
04 | crouchevent.OnServerEvent:connect( function (player) |
05 | local character = player.Character |
06 | local hrp = character.HumanoidRootPart |
07 | local hrpy = hrp.Size.Y - 1.9 |
08 | hrp.Size = Vector 3. new(hrp.Size.X, hrpy, hrp.Size.Z) |
09 |
10 | end ) |