How do you make a path between two parts?

What is the general idea between making a line between two parts, similar to games where a player has to go to a certain location and they have a line leading them to the destination ?

Is this an actual roblox service or are you using an AI to generate your content? If we want AI solutions, we’ll ask an AI ourselves.
image
image

2 Likes

Please stop using AI. Make posts with your own knowledge please. As @Vectue already proved, you used information of AI. People are already aware, you can’t become famous using AI.

Drawing.new() isn’t a service, it’s just our own constructor (basically think like it’s our own Vector3.new()), but this guy has just copy-paste the information, so you got confused.

Is there any sort of external module that needs to be downloaded?
Oh.

Nope, if you have experience with scripting and ModuleScripts, we can make our own constructors there and use it in normal scripts.

For clarity, let’s say we want to find area of a rectangular part, we’ll make module like this

local rectangle = {}

function rectangle.Area(length, breadth)
print(length * breath)
end

return rectangle

Now use it in normal scripts like this

local Rectangle = require(game.ReplicatedStorage.Module)

Rectangle.Area(20, 30)

It should print 600

As you saw, we made our own constructor Rectangle.Area()

I think the AI he used was taking data from a Synapse X post on the internet, because that’s also the only thing I found after a quick search about paths

Nonetheless people using AI to try and give solutions is a bit of a problem

1 Like

Correct, even today I didn’t used AI, but people thought I used AI because of nowadays, it’s a trend, so people thinks us suspicious.

Ok, so do you mean like an arrow pointing indicating towards a part ?

No i was looking for a line to be drawn between two parts, i’ve got a beam for now but I’m trying to get a line that is flat not like a trail

Okay, I’m sorry, I’m really embarrassed.

1 Like

If you want an animated line, a beam is the way to go. But I think you want a part so instead you should:
1- get the position of both parts
2- add the two positions then divide them by 2 to get the centre position
3- subtract the 2 points then use their .Magnitude property to determine the length of the part
4- use CFrame.lookAt from the centre point, and look at one of the points, doesn’t matter which one

local p1 = workspace.p1 -- first part
local p2 = workspace.p2 -- second part

local part = Instance.new('Part')
part.Anchored = true
part.Parent = workspace

local function updatePart()
    local startPoint, endPoint = p1.Position, p2.Position
    local centre = (startPoint + endPoint) / 2 -- this is basically the "average" position given the 2 points
    
    local length = (startPoint - endPoint).Magnitude
    
    part.Size = Vector3.new(0.1, 0.1, length) -- X is width, Y is height and Z is length
    part.CFrame = CFrame.lookAt(centre, startPoint)
end

game:GetService('RunService').Heartbeat:Connect(updatePart)

hey dude, it’s fine if you use ChatGPT and the like to help you with code. However, notice my wording. ā€œHelp.ā€ You won’t get better at scripting if you don’t try to understand it without some effort. Try using youtube tutorials for a general problem or skill, only use chatGPT if you’re really, really stumped. If not, then at least check it; it won’t be optimized and chatGPT might miss some things, so it’s worth it to look for potential errors.

1 Like

Yes bro, i really need help with the script in my place.

just use that guy’s script, i can explain it but if you need it for any specific reason without a pre-labelled part; just change the p1 or p2

1 Like

pathfinding service might help you.

or just make a beam and 2 attachments at part 1 and part 2 and give it arrow texture ĀÆ_(惄)_/ĀÆ