retasdqwe
(retasdqwe)
December 22, 2024, 5:24pm
#1
I’ve been struggling to make something like an arrow from one frame to another. And it needs to be automatic so I could just add one more frame and they will connect with eachother.
What do I want to achieve?
A new Path2D (or anything that can be automated through code or function like I want) Instance, which connects two frames when the function is fired.
Pretty rough example:
Squares are frames
Arrows are the Instance.new(“Path2D”)
Any help is appreciated! I hope I explained enough to understand
1 Like
You can use path2D:SetControlPoints .
Example:
local path2D = Instance.new("Path2D", script.Parent)
path2D.Thickness = 5
path2D.Color3 = Color3.fromRGB(0, 155, 255)
local frame1 = script.Parent.Frame1
local frame2 = script.Parent.Frame2
local frame3 = script.Parent.Frame3
path2D:SetControlPoints({
Path2DControlPoint.new(frame1.Position),
Path2DControlPoint.new(frame2.Position),
Path2DControlPoint.new(frame3.Position),
})
Make sure the frames AnchorPoint is (0.5, 0.5) so the lines are exactly in the middle
If you want to insert a new control point use path2D:InsertControlPoint
Example:
local path2D = Instance.new("Path2D", script.Parent)
path2D.Thickness = 5
path2D.Color3 = Color3.fromRGB(0, 155, 255)
local frame1 = script.Parent.Frame1
local frame2 = script.Parent.Frame2
local frame3 = script.Parent.Frame3
path2D:InsertControlPoint(#path2D:GetControlPoints() + 1, Path2DControlPoint.new(frame1.Position))
path2D:InsertControlPoint(#path2D:GetControlPoints() + 1, Path2DControlPoint.new(frame2.Position))
path2D:InsertControlPoint(#path2D:GetControlPoints() + 1, Path2DControlPoint.new(frame3.Position))
2 Likes
retasdqwe
(retasdqwe)
December 23, 2024, 4:48pm
#3
Big thank you! It worked for me from the first try, gotta figure out how to insert this into the main code block!
Btw here’s what i got from copy & pasting the script:
system
(system)
Closed
January 6, 2025, 4:48pm
#4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.