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

How to change size of a Frame via 'While true do' ?

So, I want a size of a Frame to change between values via While true do scripting, but I don't know how to set the sizes... I need help with the final step, please !

Stat = script.Parent

while true do
	Stat.Size = Stat.Size.X.Offset * 950
	wait(1)
	Stat.Size = Stat.Size.X.Offset * 450
	wait(1)
end

1 answer

✓ Accepted answer

You can use TweenSize to translate a gui between two sizes in a given time period:

local startSize = UDim2.new(0,100,0,100)
local endSize = UDim2.new(0,150,0,150)
local tweenTime = 1

script.Parent.Size = startSize
while true do
	script.Parent:TweenSize(endSize, Enum.EasingDirection.Out,Enum.EasingStyle.Quad, tweenTime)
	wait(tweenTime)
	script.Parent:TweenSize(startSize, Enum.EasingDirection.Out,Enum.EasingStyle.Quad, tweenTime)
	wait(tweenTime)
end

You can also edit the EasingDirection and the EasingStyle to customise this transition.

However, if you just wanted an instant transition between the sizes, you could just do something like this:

local startSize = UDim2.new(0,100,0,100)
local endSize = UDim2.new(0,150,0,150)
local waitTime = 1

while true do
	script.Parent.Size = startSize
	wait(waitTime)
	script.Parent.Size = endSize
	wait(waitTime)
end

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