Whenever I first equip a tool with a rope constraint attached, it teleports me to a random location. From that point on, if I equip the tool, it moves me very slightly but doesn’t teleport me. Here is an example of what I mean (the first tool I equipped I already equipped before. The second one I have not equipped before):
Why is this happening? I’ve narrowed it down to being an issue with RopeConstraints, because if I remove the rope constraints from my fishing rod tool, my character isn’t moved at all. I also noticed that welding the part that is supposed to move freely with the RopeConstraint makes this issue go away.
I need to have the rope constraint because my whole system is set up around throwing the line and detecting when it touches water. I throw the line by extending the rope length and doing some stuff with body forces.
Here is my hiarchy:
What should I do? Is this a physics bug? I’ve been trying to fix this for hours: any help is appreciated.
So the fix to this was whenever you equip the tool, I enabled the RopeConstraints which I now have disabled by default, then teleporting the part that is supposed to move freely with the rope to the player’s position. Then, after about 0.1 seconds, I enabled the ropes again.
I had this same problem with a flail weapon. I had a handle with three ropes attached to three spiky spheres. The best solution I could come up with was indeed disabling the ropes before equipping them and I used a weld constraints between the handle and the spiky spheres. When I got the equipped event, I removed the welds and enabled the ropes again. No hacky delays needed since the spheres followed the handle instantly.
Here’s the script how I did it. Place the script on the tool as a server script.
local tool = script.Parent
-----------------------------------------------------------------------------
local function getDescendantsByClass(rootInstance, className)
local descs = {}
for _,i in ipairs(rootInstance:GetDescendants()) do
if (i:IsA(className)) then
descs[#descs + 1] = i
end
end
return descs
end
-----------------------------------------------------------------------------
local welds = {}
local function weldRopes(rootInstance)
local ropes = getDescendantsByClass(rootInstance, "RopeConstraint")
for _, rope in ipairs(ropes) do
rope.Enabled = false
local weld = Instance.new("WeldConstraint")
weld.Part0 = rope.Attachment0.Parent
weld.Part1 = rope.Attachment1.Parent
weld.Parent = weld.Part0
welds[#welds + 1] = weld
end
end
local function unweldRopes(rootInstance)
for _, weld in ipairs(welds) do
weld:Destroy()
end
welds = {}
local ropes = getDescendantsByClass(rootInstance, "RopeConstraint")
for _, rope in ipairs(ropes) do
rope.Enabled = true
end
end
-- WELD ROPES BEFORE EQUIPPING IT
weldRopes(tool)
tool.Equipped:Connect(function()
unweldRopes(tool)
end)
tool.Unequipped:Connect(function()
weldRopes(tool)
end)