Issues with RodConstraints

I’m trying to develop a system where a player can use a ProximityPrompt to create a RodConstraint and then automatically attach it to two parts with included attachment points. I’m having issues with this though, as the RodConstraint won’t activate, and of course, the property is locked so it can’t be manually set.

My script is the following:

script.Parent.Triggered:Connect(function()
local coupler = Instance.new("RodConstraint")
coupler.Parent = game.Workspace.Part1
coupler.Attachment0 = game.Workspace.Part1.Attachment
coupler.Attachment1 = game.Workspace.Part1.Attachment
local distance = (game.Workspace.Part1.Position - game.Workspace.Part2.Position).magnitude
coupler.Length = distance
coupler.Visible = true
coupler.Enabled = true
script.Parent.Enabled = false

end)

If anyone has any advice on how to deal with this, it would be greatly appreciated. If it’s an obvious solution that I’m missing, I’m sorry, I haven’t dealt with constraints much so far. Thanks!

maybe give distinct names for the attachments?
since the script takes the same attachment for the both Attachment 0 and 1.

I’m actually so dumb, I never changed it to Part2 when I copied and pasted it…

Thanks for noticing that for me, saved me a good amount of time lol

1 Like