IocaIe
(IocaIe)
July 11, 2020, 2:43am
#1
Hey there!
So i have this line of code which for some reason doesn’t work:
while script.Parent.Size ~= UDim2.new(1,0,0,0) do
I want for the while loop to exit when the Y axis size is 0 (ImageLabel).
In the while loop the Y axis size increases by 0.01 every 0.001 seconds:
script.Parent.Size = script.Parent.Size - UDim2.new(0,0,0.01,0)
For some reason when the size of the ImageLabel is (1,0,0,0), you don’t exit out of the while loop
Any help is appreciated!
incapaz
(uep)
July 11, 2020, 2:45am
#2
There could be many reasons for this. The main one is likely due to floating point imprecision. It could be 1.01, or even 99.9999, you never know.
Can’t you use TweenService and then use the Tween.Completed
event?
1 Like
IocaIe
(IocaIe)
July 11, 2020, 2:47am
#3
Hm, my first thought was to use a while loop , because i need to change the size and the position, but i guess ill tween the size and position at the same time (if that’s possible).
1 Like
incapaz
(uep)
July 11, 2020, 2:49am
#4
GuiObjects come with a :TweenSizeAndPosition
method. Its last argument is a callback function that will be called with argument Enum.TweenState
of either Canceled
or Completed
.
2 Likes
rek_kie
(Ike)
July 11, 2020, 2:49am
#5
Yeah, thats literally the exact name of a built in function for tweening UI objects.
There’s three:
:TweenSize
:TweenPosition
:TweenSizeAndPosition
1 Like
IocaIe
(IocaIe)
July 11, 2020, 2:50am
#7
Oh right. Thanks for the help.