Roblox tool bug when equipping: teleports from last equipped position to character

For context, I’m using a bit of a modified tool system. Instead of connecting the tool to the character’s right arm with a weld (which is how it is in the legacy roblox tool system), my tool connects to a Motor6D located in the character’s torso. I followed @Headstackk 's tutorial to set my tools up like this.

The Issue
Using this modified tool system, whenever a tool is unequipped, then reequipped, the tool will teleport from it’s last position in workspace to the character.

This is a video of the bug:

This is the code segment that attaches an equipped tool to a character. It is in a server script in ServerScriptService:

character.ChildAdded:Connect(function(child)
			if child:IsA("Tool") then
				local BodyAttach = child:FindFirstChild("BodyAttach", true)
				if BodyAttach then
					M6D.Part1 = BodyAttach
				else
					warn(child.Name .. " is not a tool that is compatible for this game: missing BodyAttach part")
				end
			end
		end)
		character.ChildRemoved:Connect(function(child)
			if child:IsA("Tool") then
				M6D.Part1 = nil
			end
		end)

The reason for this teleporting tool bug is probably because of a delay.

Goal
I want to get rid of this delay to get rid of this bug.

1 Like

Why don’t you try, instead of assigning Part1 of Motor6D to nil, why don’t you leave it as it was before? Like, not set the Part1 to nil, just let it there

You can try this, since by setting the Motor6D to nil, the tool will stay in the last position where the tool is unequipped.

If this doesn’t work, you can try to move the position of the tool on the torso of the player (or wherever you have it) before assigning the Part1 property of Motor6D.

I have to set the Motor6D to nil when the child is removed just in case the tool is dropped. Also, I tried that solution before, & it doesn’t work when you switch between multiple weapons where the Motor6D’s part1 is changed.

As for setting the position of the tool before assigning it, that’ll probably work, but I’ll need to test it when I get back to my computer.

Ideally, the position that I set the tool to would be the position of the first key frame of that tool an equip animation track. Do you know how to get the position of a specific point in the first key frame of an Animation track?

I don’t really know, but you can check these documentation sites, these may help you

The latter suggestion did not work unfortunately. The part moves, but you can still see it teleport.

This is how I modified the code segment for testing:

character.ChildAdded:Connect(function(child)
			if child:IsA("Tool") then
				local BodyAttach : Part = child:FindFirstChild("BodyAttach", true)
				if BodyAttach then
					----
					BodyAttach.Anchored = true
					print(BodyAttach.Name)
					BodyAttach.CFrame = character:WaitForChild("HumanoidRootPart").CFrame
					print(BodyAttach.CFrame)
					print(character:FindFirstChild("HumanoidRootPart").CFrame)
					task.wait(99999999)
					BodyAttach.Anchored = false
					----
					M6D.Part1 = BodyAttach
				else
					warn(child.Name .. " is not a tool that is compatible for this game: missing BodyAttach part")
				end
			end
		end)

Sorry! I thought it would work, tbh, I dont really know why it happens, sorry!


Thanks to Hunter on discord for pointing out to me that I didn’t follow the tutorial closely enough lol.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.