Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a brick grow then shrink then repeat?

Ok so, I have this brick that grows & shrinks. The goal is it for this to repeatedly do this without any interference, but it seems after 10-15 minutes of the server being up the brick becomes far too large, and I can't seem to figure out why. Any help would be great. while true do

while true do

for i = 1, 15 do

script.Parent.Size = script.Parent.Size + Vector3.new (0.5, 0.5, 0)

wait(0.1)

end

for i = 1, 15 do

script.Parent.Size = script.Parent.Size + Vector3.new (-0.5, -0.5, 0)

wait(0.1)

end

end

1 answer

You can do that easily by using TweenService and make it repeat from the TweenInfo itself you can do it like this;

Code:

local tweenService = game:GetService("TweenService")
local part = script.Parent

local tweenInfo = TweenInfo.new(
	2, --The time it would take to do the tween
	Enum.EasingStyle.Linear, --The style it would go about the tween
	Enum.EasingDirection.Out, --Where the tween will head to
	-1, --How many it will repeat, but when the number is under 0 or smaller than 0 it will loop forever
	true, --If it will repeat or not
	0, --delay
)

local tween = tweenService:Create(part, tweenInfo, {Size = Vector3.new(5,5,5)}) --Making the tween
--The size being 5,5,5 means that the tween will make the part change it's size to 5,5,5 then return to the original

tween:Play() --and last part you start the tween, you could stop it after an amount of seconds if you want.
wait(10)
tween:Stop()

You could read more about tweens; https://developer.roblox.com/api-reference/class/TweenService

Hope this helped.

7 comments

0

He's not using the TweenService...

0

Also, for loops are ok, but repeat loops are better for this kind of thing.

0

I'm telling him to use tweenservice, so its more easier for him

0

I get an error on line 11 and have 0 clue how to fix it..

0

Send your code that had the error in another question.

0

its the exact same one you posted

0

Ok i'm very sorry for the earlier issue i wrote the code without testing it, i added an extra "," after the 0 and it was unneeded, it should work now

This discussion is preserved as it was. New answers, comments, and votes are closed.