I am creating a grow your “blank” game and need to scale the characters when the player eats “food”
a problem i ran into was the characters eyes are being pushed into the characters head and other things just aren’t proportionate
Details about the character
its one mesh
it contains a humanoidrootpart as the primarypart
what its supposed to look like all the time
but instead looks like this when i try to rescale it with my function
my function:
local character = player.Character or player.CharacterAdded:Wait()
for _, part in character:GetChildren() do
if part:IsA("BasePart") or part:IsA("MeshPart") then
part.Size += Vector3.new(Size.Value / 100000, Size.Value / 100000, Size.Value / 100000)
end
end
Size.Changed:Connect(function()
for _, part in character:GetChildren() do
if part:IsA("BasePart") or part:IsA("MeshPart") then
part.Size += Vector3.new(Size.Value / 100000, Size.Value / 100000, Size.Value / 100000)
end
end
end)
this system does alot now days it used to have some bugs but i think they worked them out it scales attachments ropes even humanoid speed which can be an issue but you can adjust for that or others
if you want to see it working my game Ant Colony Simulator uses this on the ants when they grow and also on the food when it is consumed
if its a part you need to scale just create a model instance add the part to it then scale it then remove the part back out works with groups of parts too
I ran this code for an R15 rig and it works well. overlap hitbox.rbxl (89.7 KB)
local Char = script.Parent
local Size = Char:WaitForChild("Size")
local CurrentSize = Size.Value
local function Resize()
local factor = Size.Value/CurrentSize
CurrentSize = Size.Value
for _,part in Char:GetChildren() do
if part:IsA("BasePart") then
part.Size *= factor
for _,joint in part:GetChildren() do
if joint:IsA("Motor6D") then
joint.C0 = joint.C0.Rotation + joint.C0.Position*factor
joint.C1 = joint.C1.Rotation + joint.C1.Position*factor
end
end
end
end
end
Size.Changed:Connect(Resize)
local Char = script.Parent
local Size = Char:WaitForChild("Size")
local CurrentSize = Size.Value
local function Resize()
local factor = Size.Value/CurrentSize
CurrentSize = Size.Value
for _,part in Char:GetChildren() do
if part:IsA("BasePart") then
part.Size *= factor
for _,joint in part:GetDescendants() do
if joint:IsA("Bone") then
joint.CFrame = joint.CFrame.Rotation + joint.CFrame.Position*factor
end
end
end
end
end
Size.Changed:Connect(Resize)