I need a gui object to be in a limit distance from other, but how to use it like Vector3, that has .magnitude? Do I have to calculate each vector, like:
distanceX = gui1.X.Offset - gui2.X.Offset
I need a gui object to be in a limit distance from other, but how to use it like Vector3, that has .magnitude? Do I have to calculate each vector, like:
distanceX = gui1.X.Offset - gui2.X.Offset
You can calculate the magnitude of the distance between the GUIs by comparing their AbsolutePositions:
local gui1s = gui1.AbsolutePosition
local gui2s = gui2.AbsolutePosition
local distance = (gui1s - gui2s).magnitude
yeah I've thought of that, thanks for the code
but I didn't think of using absolute pos
and since absoluteposition is vector2, there is a .magnitude
Just discovered that, the wiki didn't say it.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
I'm pretty sure you can only use Magnitude with Vectors.
That's not true
You could calculate it like that but it depends if you're using the bottom or right sides/corners. You'll need to add the width/height to the offset in that case.