Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why won't this localscript resize the HRP?

Asked by
Lyphios 77
4 months ago
Edited 4 months ago

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

0
^ You need to do it in a ServerScript 6zk8 95 — 4mo
0
Oh, I'll try that Lyphios 77 — 4mo
0
It still does nothing Lyphios 77 — 4mo
0
What exactly is the issue??? Please provide more information. brokenVectors 520 — 4mo
View all comments (9 more)
0
where did you put the script in? ByteError 32 — 4mo
0
@brokenVectors I edited Lyphios 77 — 4mo
0
if your trying to make it look like there crouching, try changing the camera position botw_legend 452 — 4mo
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. Lyphios 77 — 4mo
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 Lyphios 77 — 4mo
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 Lyphios 77 — 4mo
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. brokenVectors 520 — 4mo
0
I've been trying to get this script working since yesterday, I 'm not sure where to start re-writing Lyphios 77 — 4mo
0
Can someone just fix the script?! Lyphios 77 — 4mo

1 answer

Log in to vote
1
Answered by
rabbi99 535 Moderation Voter
4 months ago

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)
1
Thanks Lyphios 77 — 4mo
1
Now I'll make another event that fires when the player presses x to get back up Lyphios 77 — 4mo
0
Great you should figure that one out yourself! rabbi99 535 — 4mo
Ad

Answer this question