This is a useful function that Resizes everything so their is no visual bugs in bones and rigs.
This is different than ScaleTo as it Scales Tool.Grip and Attachments. All the code is written by me.
You could use this to scale anything without issue. I also added a ScaleFactor value so that you can change the ScaleFactor in real time.
The resizetween function is really cool unfortunately I’ve encountered the same issues as the ScaleTo API with this function. It currently scales the position as well
function multnumseq(sequence,Scale)
local numberKeypoints2 = {}
for i = 1, #sequence.Keypoints do
local currKeypoint = sequence.Keypoints[i]
table.insert(numberKeypoints2, NumberSequenceKeypoint.new(currKeypoint.Time,currKeypoint.Value*Scale))
end
return NumberSequence.new(numberKeypoints2)
end
function Resize(Model,Scale)
local PrevFrame=nil
if Model:FindFirstChild("HumanoidRootPart") or Model:IsA("Model") then
if Model.PrimaryPart then
PrevFrame=Model.PrimaryPart.CFrame
end
end
local vars=Model:GetDescendants()
if Model:IsA("Tool") then
local Vcf = Model.Grip
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
Model.Grip = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
end
if Model:IsA("BasePart") then
Model.Size = Model.Size * Scale
end
for k,v in next,vars do
if v:IsA("BasePart") or v:IsA("Bone") or v:IsA("Attachment") then
local Vcf = v.CFrame
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
if v:IsA("BasePart") then
v.Anchored=true
--local orig=v.Size
v.Size = v.Size * Scale
--local dif=(v.Size-orig)
v.CFrame = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
else
v.CFrame = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
end
elseif v:IsA("SpecialMesh") or v:IsA("Mesh") then
v.Scale = v.Scale * Scale
v.Offset= v.Offset * Scale
elseif v:IsA("Humanoid") then
--v.CameraOffset=v.CameraOffset*Scale
v.HipHeight=v.HipHeight*Scale
--v.WalkSpeed=v.WalkSpeed*Scale
elseif v:IsA("Motor6D") or v:IsA("Weld") then
if v.C0 and v.C1 and v.Name~="AccessoryWeld" then
local Vcf = v.C0
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
v.C0 = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
local Vcf = v.C1
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
v.C1 = CFrame.new(Vcf.p * Scale)* CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
end
elseif v:IsA("ParticleEmitter") then
v.Size=multnumseq(v.Size,Scale)
elseif v:IsA("Beam") then
v.Width0=v.Width0*Scale
v.Width1=v.Width1*Scale
v.Segments=v.Segments*Scale
v.CurveSize0=v.CurveSize0*Scale
v.CurveSize1=v.CurveSize1*Scale
v.TextureLength=v.TextureLength*Scale
elseif v:isA("Texture") then
v.OffsetStudsU=v.OffsetStudsU*Scale
v.OffsetStudsV=v.OffsetStudsV*Scale
v.StudsPerTileV=v.StudsPerTileV*Scale
v.StudsPerTileU=v.StudsPerTileU*Scale
--elseif v:IsA("NumberValue") and v.Parent.ClassName=="Humanoid" then
-- v.Value=v.Value*Scale
elseif v:IsA("Smoke") or v:IsA("Fire") then
v.Size=v.Size*Scale
elseif v:IsA("PointLight") or v:IsA("SpotLight") or v:IsA("SurfaceLight") then
v.Range=v.Range*Scale
end
end
for k,v in next,vars do
if v:IsA("BasePart") then
v.AssemblyLinearVelocity=Vector3.new(0,0,0)
v.Anchored=false
end
end
if PrevFrame~=nil then
Model:SetPrimaryPartCFrame(PrevFrame)
end
return Model
end
function ResizeNPC(Subject,Scale)
if Subject:FindFirstChild("ScaleFactor")==nil then
local check=Instance.new("NumberValue")
check.Name="ScaleFactor"
check.Parent=Subject
dfg.Resize(Subject,Scale)
end
local prevv=Subject.ScaleFactor.Value
Subject.ScaleFactor:GetPropertyChangedSignal("Value"):Connect(function()
local basev=1/prevv*Subject.ScaleFactor.Value
dfg.Resize(Subject,basev)
prevv=Subject.ScaleFactor.Value
end)
return Subject.ScaleFactor
end
function tweenemitter(v,Scale,duration)
spawn(function()
local base=v.Size
local frame=(1/30)
local timer=0
local numofframes=duration/frame
local dif=Scale-1
repeat
v.Size=multnumseq(base,1+(dif*(timer/numofframes)))
task.wait(frame)
timer=timer+frame
until timer>=duration
end)
end
function ResizeTween(Model,Scale,duration)
local tweenInfo=TweenInfo.new(duration)
local PrevFrame=nil
if Model:FindFirstChild("HumanoidRootPart") or Model:IsA("Model") then
if Model.PrimaryPart then
PrevFrame=Model.PrimaryPart.CFrame
end
end
local vars=Model:GetDescendants()
if Model:IsA("Tool") then
local Vcf = Model.Grip
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
local goalc={}
goalc.Grip = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
local tween=TweenService:Create(Model,tweenInfo,goalc)
tween:Play()
end
if Model:IsA("BasePart") then
local goalc={}
goal.Size = Model.Size * Scale
local tween=TweenService:Create(Model,tweenInfo,goalc)
tween:Play()
end
for k,v in next,vars do
if v:IsA("BasePart") or v:IsA("Bone") or v:IsA("Attachment") then
local Vcf = v.CFrame
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
if v:IsA("BasePart") then
local goalc={}
goalc.Size = v.Size * Scale
goalc.CFrame = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
goalc.AssemblyLinearVelocity=Vector3.new(0,0,0)
local tween=TweenService:Create(v,tweenInfo,goalc)
tween:Play()
else
local goalc={}
goalc.CFrame = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
local tween=TweenService:Create(v,tweenInfo,goalc)
tween:Play()
end
elseif v:IsA("SpecialMesh") or v:IsA("Mesh") then
local goalc={}
goalc.Scale = v.Scale * Scale
goalc.Offset= v.Offset * Scale
local tween=TweenService:Create(v,tweenInfo,goalc)
tween:Play()
elseif v:IsA("Humanoid") then
--v.CameraOffset=v.CameraOffset*Scale
local goalc={}
goalc.HipHeight=v.HipHeight*Scale
local tween=TweenService:Create(v,tweenInfo,goalc)
tween:Play()
--v.WalkSpeed=v.WalkSpeed*Scale
elseif v:IsA("Motor6D") or v:IsA("Weld") then
if v.C0 and v.C1 then
local Vcf = v.C0
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf:components()
local goald={}
goald.C0 = CFrame.new(Vcf.p * Scale) * CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
local Vcf2 = v.C1
local _,_,_,C0,C1,C2,c3,c4,c5,c6,c7,c8 = Vcf2:components()
goald.C1 = CFrame.new(Vcf2.p * Scale)* CFrame.new(0,0,0,C0,C1,C2,c3,c4,c5,c6,c7,c8)
local tween2=TweenService:Create(v,tweenInfo,goald)
tween2:Play()
end
elseif v:IsA("ParticleEmitter") then
tweenemitter(v,Scale,duration)
elseif v:IsA("Beam") then
local goal={}
goal.Width0=v.Width0*Scale
goal.Width1=v.Width1*Scale
goal.Segments=v.Segments*Scale
goal.CurveSize0=v.CurveSize0*Scale
goal.CurveSize1=v.CurveSize1*Scale
goal.TextureLength=v.TextureLength*Scale
local tween2=TweenService:Create(v,tweenInfo,goal)
tween2:Play()
elseif v:isA("Texture") then
local goal={}
goal.OffsetStudsU=v.OffsetStudsU*Scale
goal.OffsetStudsV=v.OffsetStudsV*Scale
goal.StudsPerTileV=v.StudsPerTileV*Scale
goal.StudsPerTileU=v.StudsPerTileU*Scale
local tween2=TweenService:Create(v,tweenInfo,goal)
tween2:Play()
--elseif v:IsA("NumberValue") and v.Parent.ClassName=="Humanoid" then
-- v.Value=v.Value*Scale
elseif v:IsA("Smoke") or v:IsA("Fire") then
local goal={}
goal.Size=v.Size*Scale
local tween2=TweenService:Create(v,tweenInfo,goal)
tween2:Play()
elseif v:IsA("PointLight") or v:IsA("SpotLight") or v:IsA("SurfaceLight") then
local goal={}
goal.Range=v.Range*Scale
local tween2=TweenService:Create(v,tweenInfo,goal)
tween2:Play()
end
end
return Model
end
This works like ScaleTo Api I guess except this is open sourced and you can use it however you like.
You could tween these CFrame and Size properties to simulate growing using any rig
I commented out the line for the CameraOffset but that may be useful to consider for your use case.
Setting the linear velocity to 0 is so the part doesn’t get yeeted out of existance which happens sometimes.
Here is a link to the model!!
ResizeDemo with Dog and Randomly Generated NPC - Roblox ResizeDemo with Dog and Randomly Generated NPC - Roblox