I got an action type animation script from YouTube, but it doesn’t seem to work. I’ve tried to find ways to fix this, like on YouTube and the Dev Forum, and also tried to fix it myself (although I have no experience) but they are not related to my problem or have not fixed it.
won’t work. Putting “animation” after the equipped function makes the “animation” bit of it call to the player’s mouse.
Ok now that’s addressed to fix it what you will need to do is put an animation in the tool, put the animation id in the animation, then make a variable in the script like so:
local animation = script.Parent.Animation
and then do (above the equipped function, under the animation variable)
local animtrack = script.Parent.Parent:FindFirstChild("Humanoid"):LoadAnimation(animation)
and then once in the equipped function do:
animtrack:Play()
and then once in the unequipped function do:
animtrack:Stop()
In the end it should look like this:
local animation = script.Parent.Animation
local animtrack = script.Parent.Parent:FindFirstChild("Humanoid"):LoadAnimation(animation)
script.Parent.Equipped:Connect(function()
animtrack:Play()
end)
script.Parent.Unequipped:Connect(function()
animtrack:Stop()
end)
Extra tip; you can’t do :Play() or :Stop() in a regular animation, you have to make an animation track like I did.
local UIS = game:GetService('UserInputService')
local equipped = false
local animation = script.Parent.Idle
local animtrack = script.Parent.Parent:FindFirstChild("Humanoid"):LoadAnimation(animation)
UIS.InputBegan:Connect(function(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 and equipped == true then
animtrack:Play()
end
end)
script.Parent.Equipped:Connect(function()
equipped = true
end)
script.Parent.Unequipped:Connect(function()
equipped = false
end)
I did do that, but when I deleted the last two sections of code (because I tried to solve it myself,) it all of a sudden stopped working.
I did before, but I ran into those two things.
Edit:
I found an article with a solution related to one of my problems. However, I’m scared that I will be told that I’m using someone else’s script and people will say that I’m copying. So I’m wondering: am I allowed to use other articles’ scripts?