Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Borrahh 265 Moderation Voter
4 years ago

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)

0
Make a variable for the animation. local anim = humanoid:LoadAnimation(game.ReplicatedStorage.Animation) ninjabryan43 0 — 4y
0
Also, print if the animation is playing or not. That makes it check if it is playing or not. print(anim.IsPlaying) ninjabryan43 0 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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

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 Borrahh 265 — 4y
Ad
Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago

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

Answer this question