How to properly check position of an object via script?

I am not sure how I should go about this:

repeat wait() until script.Parent.Parent.Position.X=={0.515, 0} and script.Parent.Parent.Position.Y=={0.61, 0}

I am checking to see once a gui tween is finished go ahead and quit out if quit was determined to be clicked on, however the above code doesn’t seem to function. Heres the tween I am waiting for considering the above conditions:

plr.PlayerGui.Shop.Weapons:TweenSizeAndPosition(UDim2.new(0.515, 0,0.61, 0), UDim2.new(0.25, 0,0.2, 0),nil,Enum.EasingStyle.Elastic,1.15)

Any thoughts?

Tweens have a Completed event, which fires when the tween finishes or when it is cancelled.

1 Like

You could just use TweenService to tween the UI that way, then detect when it’s completed using the Completed Event

You could also listen & create a callback function to detect when the Tween has completed or not using the Enum.TweenStatus Enum

1 Like

If you don’t mind me asking, how could I go about doing it for my current code?

If you want to yield the script until the tween is completed:

local TweenService = game:GetService("TweenService")

local tween = TweenService:Create(your arguments)

tween:Play()

tween.Completed:Wait()

What I mean is constructing it properly, this is what I made based off wiki info (btw its incorrect)

local ShopTween=TweenService:Create(plr.PlayerGui.Shop.Weapons, TweenInfo.new(nil, Enum.EasingStyle.Elastic,1.15), TweenSizeAndPosition(UDim2.new(0.515, 0,0.61, 0), UDim2.new(0.25, 0,0.2, 0))

In the exit button area Ill have it to where it detects until completed and proceed. but wiki isnt too helpful on how to construct it in its entirety

object,tweeninfo(parameters for style and time), tween pos and size for the designated object

I might just make another post lol: