Help with resizing the HumanoidRootPart on R6

So, I have made a little module that scales the player using ScaleTo(). However, ScaleTo() is unable to scale the HumanoidRootPart (and I also made it scale the camera offset and the gravity in workspace).

I actually managed to find a way to resize the HumanoidRootPart, however, it throws errors that I am unable to get rid of:
image

I tried pcalls, other alternatives (which either didn’t work or crashed studio), creating a fake HumanoidRootPart, Cloning HumanoidRootPart and replacing the old one (which just broke the character)
My guess is that the errors come from a Roblox engine script or something, and the fact it errors is why my script even works…

The script itself works just fine, other than the error (and the jank)

For those wondering why resize the HumanoidRootPart, it’s because if you do not resize the HumanoidRootPart, the character controller acts weird, and hitbox systems that use .Touched on the rootpart don’t work very well anymore…

Here is the code

local RunService = game:GetService("RunService")

local Player = game.Players.LocalPlayer

Player.CharacterAppearanceLoaded:Wait()

local Character : Model = script.Parent
local Humanoid : Humanoid = Character.Humanoid
local HumanoidRootPart : BasePart = Character.HumanoidRootPart

-- // Module // --

local ScaleModule = {}
local _Scale = 1

-- // Gravity // --

local ChangingGravity = false
local Gravity = game.Workspace.Gravity

local function ScaleGravity(Scale)
	ChangingGravity = true
	game.Workspace.Gravity = Gravity*Scale
	ChangingGravity = false
end

game.Workspace:GetPropertyChangedSignal("Gravity"):Connect(function()
	if ChangingGravity then return end
	Gravity = game.Workspace.Gravity
	ScaleGravity(_Scale)
end)

-- // Module Again // --

local Connection = nil

local function Scaling(Scale)
	if Connection then Connection:Disconnect() end

	local PreviousScale = _Scale

	local FloorCFrame = HumanoidRootPart.CFrame * CFrame.new(0,-3*PreviousScale,0)
	local NewHumanoidRootPartCFrame = FloorCFrame*CFrame.new(0,3*Scale,0)
	HumanoidRootPart.CFrame = NewHumanoidRootPartCFrame

	local Offset = 1.5*Scale - 1.5 -- Had to use excel to figure this one out... No idea why this is
	Humanoid.CameraOffset = (Vector3.yAxis * Offset)/Scale -- ScaleTo scales the camera offset as well, so this "unscales" it
	
	ScaleGravity(Scale)

	if Scale ~= 1 then
		warn("Ignore the errors, cannot get rid of them :(")
		HumanoidRootPart.Size = Vector3.new(2,2,1)*Scale
		Connection = HumanoidRootPart:GetPropertyChangedSignal("Size"):Connect(function()
			HumanoidRootPart.Size = Vector3.new(2,2,1)*Scale
		end)
	end
end

function ScaleModule:ScaleTo(Scale : number)
	Scaling(Scale)

	_Scale = Scale
	Character:ScaleTo(_Scale)
end

function ScaleModule:GetScale() : number
	return _Scale
end

return ScaleModule

It goes inside StarterCharacterScript
Feel free to use it, I might make it into a quick module for #resources:community-resources later on

Also, what the heck is this event?
image

Humanoids are super janky, try taking the Humanoid out, scaling the character, and then putting the Humanoid back in.

local function scaleChar(char, scale)
    local hum = char:WaitForChild("Humanoid")
    hum.Parent = nil
    hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false) -- augh why must humanoids be so weird

    char:ScaleTo(scale)

    hum.Parent = char
    hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false) -- robloz fix humanoids plz
end
2 Likes

Don’t you need to turn back on the Enum.HumanoidStateType.Dead state?

No… you don’t want your character to instantly die after scaling it, do you?

Ahhh…
I guess I don’t know how humanoids work.
(Wow, humanoids really are weird…)

I’m not, like, turning off its ability to die or anything. As I said, humanoids are super janky, and they tend to just kill themselves when parented to something else, so you just gotta re-alive it.

2 Likes

Doesn’t work, HumanoidRootPart still gets resized back to (2,2,1) when the humanoid is parented to nil. I also tried to completely delete the humanoid, and I still wasn’t able to resize the HumanoidRootPart.

One other weird thing I noticed is that, in one studio place, I can’t resize the HumanoidRootPart, but in another, I can without any issues whatsoever. The first place (where it doesn’t work) is a published placed, created a while ago. The second place (where it works) is an empty baseplate that isn’t saved.

I will investigate further when I have time to do so