I’m trying to figure out how I could visualize hitboxes (place a frame at a parts location) using frames I feel like that would be nicer them using parts I’m not exactly sure how to do this though I’m assuming I’d probably need to WorldToViewportPoint but I’m not sure how to use it to position a frame lol.
Here’s my code for making the hitboxes
local function MakePart(Size,Position,Rotation,Name,FD)
--| This part is the REAL hitbox that will make contact with the opponent
local Part = Instance.new("Part")
Part.CastShadow = false
Part.Name = Name
Part.Size = Size
Part.Position = Position + Vector3.new(0,0.5,3)
Part.CanCollide = false
Part.Anchored = false
Part.Color = Colors[Name]
Part.Material = Enum.Material.Neon
Part.Transparency = 1
if not Rotation then
Part.Orientation = Vector3.new(0,90,0)
else
Part.Orientation = Vector3.new(math.abs(Rotation[1])*FD,Rotation[2],Rotation[3])
end
local Weld = Instance.new("WeldConstraint")
Weld.Parent = Part
Weld.Part0 = Part
Weld.Part1 = Main.Character.HumanoidRootPart
Part.Parent = Main.Character
--local Camera = workspace.Camera
--local Vector,OnScreen = Camera:WorldToScreenPoint(Part.Position)
--local Frame = Instance.new("Frame")
--Frame.Parent = Main.ScreenGui
if ShowHitboxes.Value == true then
--| Fake hitbox which is a flat version of the real one for visualization
VisualHitbox = Instance.new("Part")
VisualHitbox.Name = "VisualHitbox"
VisualHitbox.Size = Vector3.new(0,Part.Size.Y,Part.Size.Z)
VisualHitbox.Orientation = Vector3.new(0,90,0)
VisualHitbox.CFrame = Part.CFrame + Vector3.new(0,0,1.3)
VisualHitbox.Color = Colors[Name]
VisualHitbox.Transparency = 0.5
local Weld2 = Instance.new("WeldConstraint")
Weld2.Parent = VisualHitbox
Weld2.Part0 = VisualHitbox
Weld2.Part1 = Main.Character.HumanoidRootPart
VisualHitbox.CanCollide = false
VisualHitbox.Parent = Main.Character
table.insert(VisualHitboxs,VisualHitbox)
end
--| Outline
local Outline = Instance.new("SelectionBox")
if ShowHitboxes.Value == true then
Outline.Transparency = 0
Outline.Adornee = VisualHitbox
Outline.Color3 = Colors[Name]
Outline.Parent = VisualHitbox
Outline.LineThickness = 0.03
end
return Part
end