✓ Accepted answer
Here's a list of problems with your code:
- At line 2: You're trying to convert a vector3 value into a number.
- At line 5: You're trying to set the the size value by using a number.
- You might want to add a wait inside the for loop if you want it to slowly increase the size
local NewSize = v.Size * 2
local SizeNumber = tonumber(NewSize)
if v.ClassName == "Part" or v.ClassName == "MeshPart" then
for i = 0, SizeNumber, 1 do
v.Size = i
end
end
How would we solve your problem?
There's multiple of creative ways of achieving your goal. The first solution that comes into my mind is using TweenService.
TweenService has just one function, TweenService:Create, which takes information about the animation and generates the Tween object which can be used to play the animation. Note that Tweens can animate multiple properties at the same time.
The full documentation can be found here
In your case, we want to create tween which has propertyTable set to your NewSize variable.
Here's what the code would look like:
local TweenService = game:GetService('TweenService')
local NewSize = v.Size * 2
if v.ClassName == "Part" or v.ClassName == "MeshPart" then
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear
)
TweenService:Create(v,tweenInfo,{
Size = NewSize
}):Play()
end
I highly encourage you to read through documentation if you find it difficult to follow along, because TweenService is service which makes a lot of your tasks easier.
I know I could've have gone into more detail about TweenService but I sadly didn't have enough time.
1 comment
Okay, I will try that.