Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Detecting if a Frame's Position(x) is at a specific position?

Asked by
Qorm 100
9 years ago

So I'm making this Tug o' war minigame for my 2D Gui and I have encountered my first problem. I'm trying to make it so if middle of my rope (which is also a frame) hits the left or right side of the Gui (which are also Frame's); and I don't exactly know on how to do this.. I tried

if script.Parent.left.MIDDLE.Position.X>=script.Parent.Parent.right.Position.X then
                print(script.Parent.Parent.Parent.Parent.Parent.Name.." wins!")
            end

Keep in mind that I just started to learn on how to script Gui's.. help would be appreciated ;)

2 answers

Log in to vote
1
Answered by 9 years ago

GUIs don't have normal position like parts, instead of using Vector3 use UDim2. For example:

Frame.Position = UDim2.new(0,50,0,50)

So try this:

if script.Parent.left.MIDDLE.Position.X.Offset>=script.Parent.Parent.right.Position.X.Offset then
                print(script.Parent.Parent.Parent.Parent.Parent.Name.." wins!")
            end

You need to edit this.


Hope it helps.

Ad
Log in to vote
0
Answered by 9 years ago

I found these two articles on the wiki which may help.

Gui Collision Tutorial & Gui Collision Detection

0
Long time no see. EzraNehemiah_TF2 3552 — 9y

Answer this question