So I recently figured out how to position a frame at a parts location by doing this
local M = game.Players.LocalPlayer:GetMouse()
local Cam = game.Workspace.CurrentCamera
function WorldToScreen(Pos) --This function gets a World Position (Pos) and returns a Vector2 value of the screen coordinates
local point = Cam.CoordinateFrame:pointToObjectSpace(Pos)
local aspectRatio = M.ViewSizeX / M.ViewSizeY
local hfactor = math.tan(math.rad(Cam.FieldOfView) / 2)
local wfactor = aspectRatio*hfactor
local x = (point.x/point.z) / -wfactor
local y = (point.y/point.z) / hfactor
return Vector2.new(M.ViewSizeX * (0.5 + 0.5 * x), M.ViewSizeY * (0.5 + 0.5 * y))
end
if ShowHitboxes.Value == true then
local Vec2 = WorldToScreen(Part.Position)
local Frame = Instance.new("Frame")
Frame.Size = UDim2.new(0.1,0,0.1,0)
Frame.Position = UDim2.new(0,Vec2.X-90,0,Vec2.Y+10)
Frame.BackgroundTransparency = 0.5
Frame.BackgroundColor3 = Colors[Name]
Frame.Parent = Main.ScreenGui
Frame.BorderSizePixel = 0
table.insert(VisualHitboxs,Frame)
end
However I wanna know if there’s a similar way to also make the size of the frame the same as the part because as you can see from this video the position is pretty accurate but the size isn’t. (the neon part is the actual hitbox which makes connects with the opponent which is invisible the frame is what’s gonna be used to show it)