So, what I have been trying to do is to create the part that expands itself until it hits to the specific size where it needs to stop and reset to the original size. Here is the script I have right now.
script.Parent.Size = Vector3.new(13,13,13)
if script.Parent.Size > Vector3.new(30,30,30) then
script.Parent.Size = Vector3.new(13,13,13)
script.Enabled = false
else
script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1)
end
I made this myself and I really dont know the error so if you figure it out please tell me.
Thanks!
Here is an example of tweening if you want the part to get bigger smoothly, you can set the target size to the size you want it to stop getting bigger at.
-- get a reference to the part you want to tween
local part = workspace.Part
-- set the target size you want the part to tween to
local targetSize = Vector3.new(2, 4, 1)
-- set the duration of the tween in seconds
local tweenDuration = 2
-- create the TweenInfo object with the desired duration and easing style
local tweenInfo = TweenInfo.new(tweenDuration, Enum.EasingStyle.Linear, Enum.EasingStyle.Out)
-- create the tween using TweenService:Create
local partTween = game:GetService("TweenService"):Create(part, tweenInfo, {Size = targetSize})
-- start the tween using Tween:Play
partTween:Play()
task.wait(4) -- so I can see it happen
---------------------------
-- A bit choppy
script.Parent.Size = Vector3.new(13,13,13)
if script.Parent.Size.X > 30 then
script.Parent.Size = Vector3.new(13,13,13)
-- script.Enabled = false
else
for s = 13, 29 do task.wait(0.1)
script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1)
end
end
So …
task.wait(4) -- so I can see it happen
---------------------------
-- smooth as glass
local ts = game:GetService("TweenService")
script.Parent.Size = Vector3.new(13, 13, 13)
function sizer(obj, _time, scale)
local info = TweenInfo.new(_time, Enum.EasingStyle.Sine,Enum.EasingDirection.InOut, 0, false, 0)
local size = {Size = Vector3.new(scale, scale, scale)}
local tween = ts:Create(obj, info, size)
tween:Play()
end
sizer(script.Parent, 10, 30)
-- the 10 is time it takes, 30 is new size
Wanted you to know that input was time. But “time” is also a command, so I used _time in the function.
Nice … I was thinking he wanted it to grow … as for your error that is there.
That’s why I used … if script.Parent.Size.X > 30 then
Just checking one value in the Vector3.