"Throb Effect" on UI

I was trying to make a sort of throb effect for my UI to make it get larger and smaller over time based on a variable. Can somebody explain why this localScript is not working in this situation?

local scale = 1
local UpOrDown = nil
while true do
	wait(1)
	if scale ==1 then
		UpOrDown = "Up"
	elseif scale==5 then
		UpOrDown = "Down"
	end
	if UpOrDown == "Up" then
		local currentX = script.Parent.Size.X
		local currentY = script.Parent.Size.Y
		script.Parent.Size = UDim2.new(0, currentX+10, 0, currentY+10)
	elseif UpOrDown == "Down" then
		local currentX = script.Parent.Size.X
		local currentY = script.Parent.Size.Y
		script.Parent.Size = UDim2.new(0,currentX+10,0,currentY+10)
	end
end
The file for testing

Random Message Generator.rbxl (27.9 KB)

This would be a good use-case for TweenService. You can tween the size to smoothly transition over time and tweening has built-in time management.

1 Like

I totally forgot about that and need to learn it. Thanks for helping!

:smiley: When you get comfortable with using Tweening, check out adjusting the EasingStyle for more depth and character to your animation if you feel it needs it.