I’m making a character customizer where players can edit their character’s sizes using the scale NumberValues in their Humanoid. (BodyDepthScale, BodyHeightScale, BodyWidthScale, etc.)
After choosing and confirming their new values, they get sent to the server to be applied after their character spawns.
I’ve got a copy of the player’s character in a ViewportFrame which I want to use as a preview for how they’ll look after being spawned, including the scale edits.
Since the scale NumberValues only work on the server though, I can’t just edit them in the preview character directly.
I assumed I could just find the scaling code in some core script somewhere, then copy and use it on the preview character, but I’ve not been able to find it anywhere.
I could use remotes to go back and forth with the server to get the scale from there but would really like to avoid all that if possible.
So now I’m a bit stuck and wondering if anyone knows where the function(s) to scale the character is located, or if it really is just built into the Humanoid itself.
If that’s the case, then does anyone have any clues to the formulas being used to get the final scales from the values?
You can apply scale* changes on the client as long as it’s a humanoid model created by the client.
Here’s an example I whipped up, copy+paste this to a LocalScript / client-context script to see it in action.
local PlayerService = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = PlayerService.LocalPlayer
local humanoidDescription = PlayerService:GetHumanoidDescriptionFromUserIdAsync(player.UserId) --Instance.new("HumanoidDescription")
local character = PlayerService:CreateHumanoidModelFromDescriptionAsync(humanoidDescription, Enum.HumanoidRigType.R15)
local humanoid = character:FindFirstChildWhichIsA("Humanoid") :: Humanoid
character.Parent = workspace
character:PivotTo(CFrame.new(0, 10, 20))
-- Ignore funny interpolation code
local function lerp(a, b, t)
return a + (b - a) * t
end
function EaseInOutSine(x: number) : number
return -(math.cos(math.pi * x) - 1) / 2
end
local minScale, maxScale = 1, 10
RunService.RenderStepped:Connect(function()
local t = time()
-- You can set the number values directly to the HumanoidDescription
humanoidDescription.DepthScale = lerp(minScale, maxScale, EaseInOutSine(t))
humanoidDescription.HeightScale = lerp(minScale, maxScale, EaseInOutSine(t + 0.5))
humanoidDescription.WidthScale = lerp(minScale, maxScale, EaseInOutSine(t))
humanoidDescription.HeadScale = lerp(minScale, maxScale, EaseInOutSine(t + 0.25))
-- Then apply it onto a humanoid that was created specifically by the client
humanoid:ApplyDescriptionAsync(humanoidDescription)
end)