I'm creating a gamepass for my game - this gamepass will allow users to purchase a 2D box ESP [only during frenzy mode], giving them an advantage over players who only have access to the radar (which I plan to have all users visible on at all times, during something I'm calling "frenzy mode" in my FPS).
To do this, I've created a simple implementation. When players leave, join, whatnot, I create a GUI for them which has 4 frames contained within it on each client that has purchased the 2d box esp. When its frenzy mode, I parent the gui's to the playergui. When it isn't, I parent it to replicatedstorage [note: I'm aware this isn't that secure, I'm just trying to get it >working< before worrying about that. I have ideas in mind].
Anyhow, to make my idea a reality - I need to draw a line 2 pixels thick [I'd settle for one if its too hard to take width into account, but I prefer 2 as 1 isn't very visible] between point A and point B.
This is fairly simple if I didn't have to account for rotation, if it's going up/down or left/right, etc. Just subtract to get the distance, use math.abs() to make it absolute, and resize the frame + position it accordingly.
However, I'm stuck when accounting for the fact that I need to be going both up/down and left/right for two lines each, AND accounting for rotation and whatnot.
I've already calculated the 2d position of the player, the topleft, topright, bottomleft, bottomright, all of that jazz - so I have the base coordinates.
The only thing left is to fill in this function, and it will be 100% functional - everything else is done, literally, including calling this function once calculating all of the math.
local function AdjustLine(LineHandle, PointOneX, PointOneY, PointTwoX, PointTwoY, Color, Thickness)
--\\Fill in my line here... smh I suck at math...
end;
This is the function I'm trying to fill in. Now to make it clear here, -I'M NOT asking for a spoonfeed or fully written code. I'd just like to know if someone can shed some light on the math/implementation behind this (preferably explaining it like I'm 5, because I can barely comprehend algebra tbh).
And I hope this question is found relevant to others and not deleted/downvoted - because I'm sure while the reason behind it isn't exactly the same, SOMEONE else has to be or will be or has been wondering how to draw a line between 2 points.

15 comments
EDIT: to make it clear, I'm trying to adjust 'LineHandle' to fit those requirements.
If you cannot do the math needed then you probably shouldn't be doing this. But nonetheless here's something that might help: https://www.robloxdev.com/api-reference/datatype/Ray
I'm trying to learn the math, not be put down. I'm already 99% of the way there - I've calculated 2d positions [converted from 3d], gotten the topleft, topright, bottomright, bottomleft, etc and called the AdjustLine function. I'm literally just asking for a point in direction for a (I think) simply piece of math.
Also that's like saying I shouldn't learn the math if I already don't know it, it makes no sense @sjr04alt. Anyhow, rays aren't what I'm looking for :/ but thanks for trying. No offense to all of this btw.
In no way was my comment meant to be taken negatively. My comment had no intent of putting you down; according to this post you didn't even try to do some kind of research.
Well you ARE being negative, so regardless of your intentions, go away. According to this post? I never said that, you're pulling words out of your butt and trying to put them in my mouth, which is gross. I've been researching this for a couple hours and cant find anything that applies to ROBLOX. Stop making assumptions, just go.
that's disgusting vocabulary, stop it. This seems to be only a bit advanced to you, that was my point. I'm not trying to say you're inexperienced, that's all.
I've been programming since 2012, it's not beyond my grasp, I just don't know where I would study how to implement such a thing.
Literally just look up "draw 2d lines between two points roblox"
Yes and that turns up one result of laggy, inefficient, unexplained, hard to read code. As I've said I've been researching this. Clearly you just make the assumption I'm lazy, so GO AWAY.
sjr, if you don't have any useful contributions to the question, stop trying to berate the op and leave it alone, thank you.
also, can't you just create the esp on the client, if nobody else is going to see it except the client? you can also use billboard guis also generated from the client to make the box esp too. i may be attempting to understand the question the wrong way. lmk?
all wrong wrong wrong wrong
If it's wrong, then provide an answer. Don't be a stuck up jerk and keep the answer for yourself. As I stated beforehand, if you don't have any useful contributions, then keep it to yourself. And, While wait() do is acceptable practice. Just because one person can't read it doesn't mean that nobody else can. Stop spreading misinformation. Sorry to el burst yur bubble.
This is the most heated comments thread I've ever seen on this site lol.