How to make a tool's handle play an animation

I’m currently trying to create a gun that follows a system similar to the game Isle’s gun system, and right now I’m working on adding animations to the weapon.

However, when I add the animations to the weapon, they do play, but the tool’s handle doesn’t play any keyframes of the animations that I made.

The weapon should move back a little when it fires like this:
https://streamable.com/aw3hip

Instead, the weapon is being fired without the handle playing this animation, like this:
https://streamable.com/pm35h0

Also, I don’t know if you can see this too, but the weapon’s grip rotation and position is also off from the rig/dummies handle keyframes.

So far, I have tried to disable Roblox’s default grip weld and replace it with a Motor6D, that did not worked. I have tried the opposite, deleting the Motor6D and using the default grip weld, that too did not work. I tried disabling the toolnone animation in the player’s animate script, did not work. I tried to manually adjust the grip to see if it did anything, that did also didn’t work.

The script that I use for the gun goes as follows (I’m sorry if you read this):

local RunService = game:GetService("RunService")
--local AnimationService = game:GetService("AnimationClipProvider")

local Player = game.Players.LocalPlayer

local Motor6D = Instance.new("Motor6D")
Motor6D.Parent = script.Parent
Motor6D.Part0 = Player.Character.RightHand
Motor6D.Part1 = Motor6D.Parent

local IdleAnimation = script.Parent.Idle
local IdlePlayer = Player.Character.Humanoid:LoadAnimation(IdleAnimation)

local AimInAnimation = script.Parent.AimIn
local AimInPlayer = Player.Character.Humanoid:LoadAnimation(AimInAnimation)

local FireAnimation = script.Parent.Fire
local FirePlayer = Player.Character.Humanoid:LoadAnimation(FireAnimation)

local TakeDamage = game:GetService("ReplicatedStorage").Remote.TakeDamage

local tool = script.Parent.Parent
local Mouse = Player:GetMouse()
local mousePos
local look
local hrp
local Target
local model

local isAiming = false
local canFire = false

tool.Activated:Connect(function()
	Target = Mouse.Target
	if isAiming == false and canFire == false then
		AimInPlayer:Play()
		RunService.RenderStepped:Connect(function()
			if Target and Target:FindFirstAncestorOfClass("Model") and Target:FindFirstAncestorOfClass("Model").Name ~= Player.Name then
				model = Target:FindFirstAncestorOfClass("Model")
				if model:FindFirstChild("Humanoid") then
					Player.Character.RightHand.RightGrip.Enabled = false
					isAiming = true
					Player.Character.Humanoid.WalkSpeed = 8
					hrp = Player.Character.HumanoidRootPart
					mousePos = Vector3.new(model.PrimaryPart.Position.X, model.PrimaryPart.Position.Y, model.PrimaryPart.Position.Z)
					look = Vector3.new(model.PrimaryPart.Position.X, hrp.CFrame.Position.Y, model.PrimaryPart.Position.Z)
					hrp.CFrame = CFrame.new(hrp.CFrame.Position, look)

					task.spawn(function()
						while isAiming == true do
							look = look
							hrp = hrp
							hrp.CFrame = CFrame.new(hrp.CFrame.Position, look)
							task.wait(0.02)
						end
					end)
				end
			end
		end)
		
		task.wait(3)
		canFire = true
		
	elseif isAiming == true and canFire == true then
		AimInPlayer:Stop()
		FirePlayer:Play()
		TakeDamage:FireServer(model)
		--model.Humanoid.Health -= 75
		isAiming = false
		canFire = false
		Player.Character.Humanoid.WalkSpeed = 16
		Target = nil
		IdlePlayer:Play()
	end
end)

tool.Unequipped:Connect(function()
	isAiming = false
	canFire = false
	AimInPlayer:Stop()
	IdlePlayer:Stop()
	Player.Character.Humanoid.WalkSpeed = 16
	Target = nil
end)

tool.Equipped:Connect(function()
	IdlePlayer:Play()
end)

I would also like to know if there any more efficient ways to play animations than the current method I am using, as I feel mine is quite inefficient and requires to many different LoadAnimation methods.

1 Like

Something I noticed was that after changing the firing animations priority to action 2, the handle was animated. However, it appears that when initially equipped, the handle is facing the way the grip was set and not the way the handle was animated.

1 Like

Example:
https://streamable.com/n880kl