Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The Animation is not Playing when I am Equipping a Gun?

I tried making an UserInputService, when player presses Q, the animation plays, and it worked fine.

But when I try to make the same but when the tool is clicked it doesn't work. I don't get any error or anything, it just won't play, am I missing something?!

local Mouse = game.Players.LocalPlayer:GetMouse()

script.Parent.Activated:Connect(function()
if Mouse.Target then
		if Mouse.Target.Parent:FindFirstChild("Humanoid") then
			print("There is humanoid")
			script.Parent.RemoteEvent:FireServer(Mouse.Target)
			game.Players.LocalPlayer.Character.Humanoid.Animator:LoadAnimation(game.ReplicatedStorage.Animation):Play()
		else
			print("No Humanoid")
		end
	end
end)

2 comments

0

Make a variable for the animation. local anim = humanoid:LoadAnimation(game.ReplicatedStorage.Animation)

0

Also, print if the animation is playing or not. That makes it check if it is playing or not. print(anim.IsPlaying)

2 answers

Well It Might Not Be A Problem In Your Script, But Did You Add The Animation?

1 comment

0

Yes mate as I said, i tried making it when player clicks Q, and everything worked fine, it doesn't work well when i hold the gun

That's because Mouse.Target has built-in filter for all Characters. You can only do this using Raycasting.

This discussion is preserved as it was. New answers, comments, and votes are closed.