How would i make a tool with a thirdperson idle and walk anim that uses weapon

Im making a game similar to garry’s mod and i am trying to make a physics gun that when equipped changes the players current idle anim to a custom then change back.

But the problem is i want to animate the physics gun in the animation, but i dont know how.

I have tried creating motor6Ds but nothing seemed to work, anyone know how?

Current script and animation

-- Variables

local idle = {}
local char;

-- Logic

script.Parent.Equipped:Connect(function()
	local animate = script.Parent.Parent:FindFirstChild("Animate")
	if animate then
		-- INIT
		char = script.Parent.Parent
		-- MOTOR6D
		local motor6D = Instance.new("Motor6D")
		motor6D.Parent = script.Parent
		motor6D.Part0 = script.Parent.Parent:WaitForChild("RightHand")
		motor6D.Part1 = script.Parent:WaitForChild("Handle")
		motor6D.Name = "weaponMotor6D"
		-- ANIMATE
		for _, v in next, animate:WaitForChild("idle"):GetChildren() do
			if v:IsA("Animation") then
				idle[v.Name] = v.AnimationId;
				v.AnimationId = script.Parent:WaitForChild("Animations"):WaitForChild("idle").Value
			end
		end
	end
end)

script.Parent.Unequipped:Connect(function()
	local animate = char:FindFirstChild("Animate")
	if animate then
		for _, v in next, animate:WaitForChild("idle"):GetChildren() do
			if v:IsA("Animation") then
				v.AnimationId = idle[v.Name]
			end
		end
		table.clear(idle)
	end
end)

1 Like

nevermind guys i fixed it using tool grip

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