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

How would I go about making a GUI object rotate to point towards a UDim2?

Asked by 7 years ago

I'm trying to make an arrow icon on the screen rotate point to a specific UDim2, but I'm not sure how to go about it.

1 answer

Log in to vote
1
Answered by 7 years ago

Some interesting math.

arrow=script.Parent
arrow_center=arrow.AbsolutePosition+arrow.AbsoluteSize/2 --grab center position of the image
spot=UDim2.new(0, 76, 0, 72) --Best if offset is used in this case
new_spot=Vector2.new(spot.X.Offset-arrow_center.X, spot.Y.Offset-arrow_center.Y) --Make the arrow act like point 0

c=math.deg(math.atan2(new_spot.Y, new_spot.X))+0 --Add or remove according on which direction the arrow is facing in the original picture. If the arrow was originaly pointing to the right then you should be fine. 
arrow.Rotation=c
Ad

Answer this question