With the item drops in my game when they appear I have a local script that tweens the scale of them so that they quickly ‘grow’ into existence. The issue I think is with using ScaleTo(), but maybe I’m doing something wrong, and maybe we can fix it anyways? When scaling a model comprised of several parts repeatedly it seems that there’s a small chance that one or more of the parts inside the model will get scaled MASSIVE and stay that way even after the tween is finished and the model clearly has a scale of 1.
I took a video to demonstrate:
As far as solutions I’ve tried using a coroutine, waits in various places, manually setting the scale to 1 at the end of the tween… I also tried tweening all the parts in the model at the same time but that is giving really bad performance issues.
local function GrowPickup(Pickup)
local elapsed = 0
local scale = 0
local tweenConnection
local function onStep(dt)
elapsed = math.min(elapsed + dt, GrowTween.Time)
local alpha = TweenService:GetValue(elapsed/GrowTween.Time, GrowTween.EasingStyle, GrowTween.EasingDirection)
scale = math.abs(StartScale+alpha*(EndScale - StartScale))
Pickup:ScaleTo(scale)
if elapsed >= GrowTween.Time then
Pickup:ScaleTo(EndScale)
tweenConnection:Disconnect()
end
end
tweenConnection = RunService.Heartbeat:Connect(onStep)]]
end
DropsFolder.ChildAdded:Connect(function(Child)
repeat task.wait() until Child.PrimaryPart
GrowPickup(Child)
end)
Now here’s the code of my tweening all the parts sizes at once (which causes performance issues)
local function GrowPickup(Pickup)
local Parts = Pickup:GetChildren()
for i = 1, #Parts do
local Goal = {}
Goal.Size = Parts[i].Size
Parts[i].Size = Vector3.new(.01, .01, .01)
local tween = TweenService:Create(Parts[i], GrowTween, Goal)
tween:Play()
end
end
DropsFolder.ChildAdded:Connect(function(Child)
repeat task.wait() until Child.PrimaryPart
GrowPickup(Child)
end)
Turns out waiting for all the children in the model to load before scaling it fixes the problem