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

May I have help as to why my animation script is not working?

Asked by 3 years ago

How my script works is that when the tool is activated it plays an animation, it is for a sword.

I am terrible with animations lol so heres the script!

local tool = script.Parent

local Damage = script.Parent:WaitForChild("DamageAmount").Value

tool.Activated:Connect(function()

local anim = script.Parent:WaitForChild("Slice")

local char = script.Parent.Parent

local animTrack = char.Humanoid.Animator:LoadAnimation(anim)

animTrack:Play()

tool:WaitForChild("Sword").Touched:Connect(function(hit)
    local player = script.Parent.Parent.Name
    local touched = hit.Parent

    if touched.Name ~= player then
        if touched:FindFirstChild("Humanoid") then
            touched.Humanoid.Health = touched.Humanoid.Health - Damage
        end
    end

end)

end)

1 answer

Log in to vote
0
Answered by
Mr_Pure 129
3 years ago
Edited 3 years ago

When Loading your animation, you only need to access the humanoid you're playing the animation on.

local animTrack = char.Humanoid.Animator:LoadAnimation(anim)

Should really just be

local animTrack = char.Humanoid:LoadAnimation(anim)

if this doesn't work i apologize, but this should fix ur issue.

0
It does not work. I have already done this before and it didnt work because somebody told me it was deprecated. NotOreo9 8 — 3y
Ad

Answer this question