Gun equipped animation script!

Hey everyone…

I’ve been having some issues with my animation when a weapon is equipped…

Here is the gun and its containings:
image

And here is the “AnimateHold” script

local plr = game:GetService("Players").LocalPlayer
local anim = script.Parent.Hold
local tool = script.Parent
local animator
local loadedAnims = {}
tool.Equipped:Connect(function(mouse)
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	if not loadedAnims then
		loadedAnims = animator:LoadAnimation(anim)
	end
	loadedAnims:Play()
end)

tool.Unequipped:Connect(function()
	loadedAnims:Stop()
end)

The animation creator is set to the same as the game creator so i dont know why this doesnt work

Do you have an error message at all?

Whenever I equip the gun this happens in the output log thing
image

Try this!

local plr = game:GetService("Players").LocalPlayer
local anim = script.Parent.Hold
local tool = script.Parent
local animator
local loadedAnims = false
tool.Equipped:Connect(function(mouse)
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	if loadedAnims == false then
		loadedAnims = plr.Character.Humanoid:LoadAnimation(anim)
	end
	loadedAnims:Play()
end)

tool.Unequipped:Connect(function()
	loadedAnims:Stop()
end)

Ill try it out! Ill update you in a min

I think you’ve called the wrong thing like the me inside players instead of the me inside workspace

Oops, I didn’t call the plr.Character!

Here

local plr = game:GetService("Players").LocalPlayer
local anim = script.Parent.Hold
local tool = script.Parent
local animator
local loadedAnims = false
tool.Equipped:Connect(function(mouse)
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	if loadedAnims == false then
		loadedAnims = plr.Character.Humanoid:LoadAnimation(anim)
	end
	loadedAnims:Play()
end)

tool.Unequipped:Connect(function()
	loadedAnims:Stop()
end)

Im not getting any error messages anymore, but the anim still isn’t playing
image

That’s strange, I think if you just uploaded the animation then you have to wait a little bit.

I uploaded it quite a bit ago
Ill try to re-animate it!

Okay, sounds great to me. If it doesn’t work try looking up some tutorials on YouTube. I’m pretty sure AlvinBlox made some pretty good ones that are easy to understand.

Omg! I am so stupid, I forgot to set the avatar to R6… Ima go test it out and see if that was the reason why :sweat_smile:

Oh, haha. Looks like you got it figured out!

Yep! I figured it out! Thank you for helping me out here mate!
:white_check_mark:

Of course, glad to help anytime.

1 Like