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

This animation will not play. Help please?

Asked by
pwnd64 106
9 years ago

I'm trying to make an animation for a tool that I made. I've followed the wiki and googled around, but nothing I do seems to work!

Here's the code -

local tool = script.Parent
local player = game.Players.LocalPlayer
local hum = player.Character:WaitForChild("Humanoid") --setting variables

local swing = tool.swinginganim --setting animation variable
local AnimTrack = hum:LoadAnimation(swing) --loading animation
local canplay = true
local swinging = false
local hitnum = 0


script.Parent.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function(hitting)
if canplay == true then
    canplay = false
    swinging = true

AnimTrack:Play() --playing the animation
wait(2)
canplay = true
swinging = false
hitnum = 0
print 'done'
end
end)
end)


tool.Handle.Touched:connect(function(touch) --giving resources when you hit
    if swinging == true and hitnum == 0 then
        if touch.Name == "resource" then
            print 'found resource node'
            hitnum = hitnum+ 1
            wait(.75)
            player.iron.Value = player.iron.Value + 1
        end
    end
end)

Thanks for reading.

0
Sometimes animations don't work if you're running them in studio from a file. Is this the problem? You should get some output like 'Asset is not trusted for this place' or something like that. Perci1 4988 — 9y
0
No, I don't get any output except the prints. pwnd64 106 — 9y
0
In-game, I got an error on line 3 where I didn't have the character yet, so I fixed that. Now I get an error where the asset is not trusted for this place. Is there a way to fix that? pwnd64 106 — 9y

Answer this question