Why is my gun acting weirdly?

ok , so the code sample is

ocal function playAnimationFromServer(character, animation)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		-- need to use animation object for server access
		local animator = humanoid:FindFirstChildOfClass("Animator")
		if animator then
			local animationTrack = animator:LoadAnimation(animation)
			animationTrack:Play()
			return animationTrack
		end
	end
end

“need to use animation object for server access” Animation object? I’m sorry if this answer is really obvious its really late and this is new stuff and i’ve been looking for a clue for multiple hours.

dont go instantly to rescripting your stuff :LoadAnimation() still works there are just better alternatives at the moment
Try checking if the Animation has an Id

the animation does have an Id, and im not getting any errors from my script.

–X

after a bit of testing i think :LoadAnimation() doesnt work anymore i dont know why
But try looking at the Animator class
i havent had to work with animators so im just as in the dark as you

Edit: For some reason now its working no changes just started working

oh ok, thanks anyway

Edit: oh ok…
signed,

X

This is wierd but try this

Tool.Equipped:Connect(function()
    local Human = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
    if not Human then
        Human = Tool.Parent:WaitForChild("Humanoid")
    else
       local AnimationTrack = Human:LoadAnimation(Animation)
       AnimationTrank:Play()
    end
end)

Also is this a Local Script or Server Script?

its a local script.

signed,
–X

try using it in a Server Script thats what i used and it worked(Although it should work from a local script)

I just realized You have the Animation set to Idle

Try setting it to movement or action if that doesnt work ive got nothing

It seems to me like you’re animating a gun rig, but never attaching it to the character at run-time… I’m pretty sure you need to attach BodyAttach to your character somehow, I don’t know how your rig is meant to be used, but you definitely need to do this, also - since you’re using a tool, you need to remove the RightGrip weld in the character’s RightHand!!

is there any errors? also it may be because your using the activated function, not the equipped function, activated is fired when you click while holding the tool and equipped is fired when you equip the tool

Any animation using conventional tools will be over ridden. To add on load animation is deprecated and should use the new animator instead. To add on to that you want to be using the body attach method in which you use motor 6ds to attach the gun to the player instead of using conventional animations in which you would see in older roblox games. How to animate Tool Parts (Guns, Knifes etc.)

load animations directly in animator, and not in humanoid

the tutorial you linked was the tutorial I used.

Thanks,
–X

how exactly would I use that?

sorry for the late replies guys,
–X

just type Character.Humanoid.Animator instead of Character.Humanoid

that dosen’t work either.

Thanks,
X

I think I found the issue, if this is idle gun animation, then do Tool.Equipped:Connect(function()

ok I will go and try that

Thanks,
X

Thanks to everyone who responded, I’ve figured it out and got it to work. Turns out it was the animation