Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this localscript resize the HRP?

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.

local Player = game.Players.LocalPlayer
local Character = Player.Character
local CharAnimation
local hrp = Character;FindFirstChild("HumanoidRootPart")
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.C then
		hrp.Size = Vector3.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

13 comments

0

^ You need to do it in a ServerScript

0

Oh, I'll try that

0

It still does nothing

0

What exactly is the issue??? Please provide more information.

0

where did you put the script in?

0

@brokenVectors I edited

0

if your trying to make it look like there crouching, try changing the camera position

0

I put the script into StarterCharacterScripts inside a localscript,I feel like it needs to be rewritten but don't know what to write.

0

Also bot no I'm trying to make the character physically move down, and I do that by changing the size of the hrp

0

Also bot no I'm trying to make the character physically move down, and I do that by changing the size of the hrp

0

Have you tried debugging this yourself? I recommend taking at least 3 hours to solve a problem before taking it to a forum like scriptinghelpers.

0

I've been trying to get this script working since yesterday, I 'm not sure where to start re-writing

0

Can someone just fix the script?!

1 answer

✓ Accepted answer

Before you start, make a RemoteEvent in ReplicatedStorage called "Crouch"

This is the localscript that is located in StarterPlayerScripts:

local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")
local crouchevent = rp:WaitForChild("Crouch")

uis.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		crouchevent:FireServer()
	end
	
end)

This is the script thats located in ServerScriptService:

local rp = game:GetService("ReplicatedStorage")
local crouchevent = rp:WaitForChild("Crouch")

crouchevent.OnServerEvent:connect(function(player)
	local character = player.Character
	local hrp = character.HumanoidRootPart
	local hrpy = hrp.Size.Y - 1.9
	hrp.Size = Vector3.new(hrp.Size.X, hrpy, hrp.Size.Z)
	
end)

3 comments

1

Thanks

1

Now I'll make another event that fires when the player presses x to get back up

0

Great you should figure that one out yourself!

This discussion is preserved as it was. New answers, comments, and votes are closed.