Why does my tool slowly get offset when moving?

local function attack()
	if debounce == false then 
		local humanoid = tool.Parent:WaitForChild("Humanoid")
		debounce = true
		Attacking.Value = true
		local animate = humanoid:LoadAnimation(animation)
		tool.Handle.Orientation = Vector3.new(90, 0, 0)
		animate:Play()
		animate.Stopped:Connect(function()
			tool.Handle.Orientation = Vector3.new(0, 0, 0)
			Attacking.Value = false
			task.wait(1)
			debounce = false
		end)
		
	end
end

Pretty much when the tool returns to it’s normal position after attacking but when im moving and animation plays this is what happens to the tool.
image
Any help would be much appreciated. I want the player to still be able to attack while running but I don’t want the tool getting displaced.

You can try setting the tool’s position to its original position after the attack animation is finished. You can store the original position of the tool at the beginning of the script like this:

local tool = script.Parent
local originalPosition = tool.Handle.Position

Then, in the Stopped event of the animation, you can reset the position of the tool:

animate.Stopped:Connect(function()
	tool.Handle.Orientation = Vector3.new(0, 0, 0)
	tool.Handle.Position = originalPosition -- reset position
	Attacking.Value = false
	task.wait(1)
	debounce = false
end)

This should prevent the tool from slowly drifting away from its original position over time.

1 Like

I didn’t even think to try that! tysm!

1 Like

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