Hey developers!
I am trying to draw a line between 2 UI points.
Here is the current code, I have left a comment where the line drawing should go.
In this case, Line1
should be connecting Shirt1
and Shirt2
- and Line2
should be connecting Pants1
and Pants2
.
local Line1 = Instance.new("Frame", script.Parent)
local Line2 = Instance.new("Frame", script.Parent)
game:GetService("RunService").RenderStepped:Connect(function()
local ClosestRig = nil
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
for _, Folder in pairs(game.Workspace.Areas:GetChildren()) do
for _, Rig in pairs(Folder:GetChildren()) do
if Rig:FindFirstChild("HumanoidRootPart") then
if not ClosestRig or (Rig.HumanoidRootPart.Position-Character.HumanoidRootPart.Position).magnitude < (ClosestRig.HumanoidRootPart.Position-Character.HumanoidRootPart.Position).magnitude then
ClosestRig = Rig
end
end
wait()
end
end
local Pants1 = script.Parent.Pants1
local Pants2 = script.Parent.Pants2
local Shirt1 = script.Parent.Shirt1
local Shirt2 = script.Parent.Shirt2
if ClosestRig and (ClosestRig.HumanoidRootPart.Position-Character.HumanoidRootPart.Position).magnitude < 10 then
Pants1.Visible = true
Pants2.Visible = true
Shirt1.Visible = true
Shirt2.Visible = true
local D3ToD2 = workspace.CurrentCamera:WorldToScreenPoint(ClosestRig.PantsAnchor.Position)
Pants1.Position = UDim2.new(0, D3ToD2.X-(Pants1.Size.X.Offset/2), 0, D3ToD2.Y-(Pants1.Size.Y.Offset/2))
D3ToD2 = workspace.CurrentCamera:WorldToScreenPoint(ClosestRig.ShirtAnchor.Position)
Shirt1.Position = UDim2.new(0, D3ToD2.X-(Shirt1.Size.X.Offset/2), 0, D3ToD2.Y-(Shirt1.Size.Y.Offset/2))
------------------------------------------------
----------- LINE DRAWING HERE
------------------------------------------------
else
Pants1.Visible = false
Pants2.Visible = false
Shirt1.Visible = false
Shirt2.Visible = false
end
end)
I honestly have no idea how to go about creating this, does anyone have ideas/suggestions to try?
Thanks!