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:
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