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

[SOLVED] Animation will not play inside of tool, no errors?

Asked by 4 years ago
Edited 4 years ago

I'm using this simple LocalScript inside of a tool inside ServerStorage being replicated to the player's backpack.

script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
            local animation =           game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
            animation:Play()
        print("played")
        end)
end)

(Sorry if formatting errors.) Every time I click, it prints "played" like it's supposed to, without any errors. I have the animation set to the highest priority; it just won't play! I've done everything I could think of! Please help!

0
It may be a problem with the animation itself being broken. I will try reanimating and see if it works. ethersend 38 — 4y

3 answers

Log in to vote
0
Answered by
seikkatsu 110
4 years ago

ok so as i am aware, mouse button 1 down event is depricated and you should use user input service you can find a lot of tutortials on yt but here's a small example:

local uis = game:GetService("UserInputService") -- here you get the service 
uis.InputBegan:Connect(function(input) --  this is the input began event.
                                                               -- there is also a input ended event but stick to this one                    
                                                                   for now, until you get better
    local mouseIn = input.UserInputType --  here you define the mouse click
                                   --user input service tells the script that you are going 
                                                                       to want to detect a mouse input
                                                                   -- there is also KeyCode and it's used in the same way
    if mouseIn == Enum.UserInputType.MouseButton1 then -- here you check if the player has 
                                                                                 hit a mouse button, more specifically mb1

    end
end)

let me know if you need any more help and don't forget to hit that accept answer button if this helped you!

0
Thanks, but i've checked the wiki and Button1Down is not deprecated. It also prints "played" when I click, so clearly this isn't the problem. [EDIT] I don't think this is the problem, but I will use it, because the wiki says to use it instead. ethersend 38 — 4y
0
Nope. Not the problem. Animation still refuses to play. Actually even worse now because "played" is printed even with the tool being unequipped. ethersend 38 — 4y
0
sooooo your problem might be the animation not the script set the priority of it to action seikkatsu 110 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Maybe try using the “Activated” function with the tool.

script.Parent.Equipped:Connect(function()
    script.Parent.Activated:connect(function()
            local animation =           game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
            animation:Play()
        print("played")
end)
end)

Log in to vote
0
Answered by 4 years ago

Sorry for all the trouble. Turns out my animation itself was broken, and consisted of nothing. I made a new one and it works fine.

Answer this question