What do you want to achieve?
I have written a script that increases a player’s body proportions by a certain amount when they join the game. However, when I replace the starter character with a custom character, the script runs correctly but the character does not scale correctly.
What is the issue?
The issue is that when the player starts resizing, it is done incorrectly. Please see the video to observe the problem.
More Information
Scale function
function alterLimb(limb)
-- Select a random alteration type
local alterationTypes = {"Scale Increase"}
local alterationType = alterationTypes[math.random(#alterationTypes)]
-- Alter the limb based on the selected alteration type
if limb.Name == "HumanoidRootPart" then
-- If the limb is the HumanoidRootPart
if alterationType == "Scale Increase" then
local humanoid = limb.Parent:FindFirstChild("Humanoid")
local currentBodyDepthScale = humanoid.BodyDepthScale.Value
local newBodyDepthScale = currentBodyDepthScale + .1
local currentBodyWidthScale = humanoid.BodyWidthScale.Value
local newBodyWidthScale = currentBodyWidthScale + .1
local currentBodyHeightScale = humanoid.BodyHeightScale.Value
local newBodyHeightScale = currentBodyHeightScale + .1
humanoid.BodyDepthScale.Value = newBodyDepthScale
humanoid.BodyWidthScale.Value = newBodyWidthScale
humanoid.BodyHeightScale.Value = newBodyHeightScale
else
print("Invalid alteration type: " .. alterationType)
return
end
end
end
Screen Shot 2022-12-29 at 9.49.58 AM530×1362 131 KB
Code
Screen Shot 2022-12-29 at 9.51.14 AM524×842 74 KB
Screen Shot 2022-12-29 at 9.51.26 AM534×842 75 KB
Screen Shot 2022-12-29 at 9.51.47 AM524×842 76 KB
**The script runs correctly but the character does not scale correctly when the HumanoidRootPart is scaled.
This is a scripting issue
I have checked the Scripting Docs and searched and could not find a solution.
This issue is reproducible
I have attached a video and created a custom character and script to illustrate the issue.
How to reproduce this issue
Please follow the instructions below to reproduce the issue
Create a new empty place
Add a custom character with a HumanoidRootPart
Create the following script and add it to the ServerScriptService
function alterLimb(limb)
– Select a random alteration type
local alterationTypes = {“Scale Increase”}
local alterationType = alterationTypes[math.random(#alterationTypes)]
-- Alter the limb based on the selected alteration type
if limb.Name == "HumanoidRootPart" then
-- If the limb is the HumanoidRootPart
if alterationType == "Scale Increase" then
local humanoid = limb.Parent:FindFirstChild("Humanoid")
local currentBodyDepthScale = humanoid.BodyDepthScale.Value
local newBodyDepthScale = currentBodyDepthScale + .1
local currentBodyWidthScale = humanoid.BodyWidthScale.Value
local newBodyWidthScale = currentBodyWidthScale + .1
local currentBodyHeightScale = humanoid.BodyHeightScale.Value
local newBodyHeightScale = currentBodyHeightScale + .1
humanoid.BodyDepthScale.Value = newBodyDepthScale
humanoid.BodyWidthScale.Value = newBodyWidthScale
humanoid.BodyHeightScale.Value = newBodyHeightScale
else
print("Invalid alteration type: " .. alteration