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

Why aren't my animation's playing?

Asked by
1JBird1 64
3 years ago

So I've been trying to make a working melee weapon, and so far it isn't working, can someone help me out here?

I have a local script that sends a message through a remote event to the this script when ever an action is done (e.g. equipped) the only thing sent through the remote event is the sound.

I also believe the script doesn't deal any damage to the player it hits.

if the local script is needed I can also show that too.

heres the script:

-- variables
local tool = script.Parent
local itemEvents = tool.ItemEvents

-- server event when item is equipped
itemEvents.Equip.OnServerEvent:Connect(function(player, sound)
    humanoid = tool.Parent.Humanoid
    humanoid:LoadAnimation(script.Equip)
    sound:Play()
    humanoid:LoadAnimation(script.Idle)
end)

-- server event when item is unequipped
itemEvents.Unequip.OnServerEvent:Connect(function(player, animationidle, sound)
    sound:Play()
    for i,c in pairs(humanoid:GetPlayingAnimationTracks()) do
        if c.Animation.AnimationId == animationidle then
            c:Stop()
        end
    end
end)

-- server event when item is activated
itemEvents.Swing.OnServerEvent:Connect(function(player, sound)
    humanoid:LoadAnimation(script.Swing)
    wait(tool:WaitForChild("SwingSoundDelay").Value)
    sound:Play()
end)

-- server event to deal damage to player 
itemEvents.Dealdamage.OnServerEvent:Connect(function(player, otherplayer, sound, value)
    otherplayer.Character.Humanoid:TakeDamage(tool.Damage.Value)
    sound:Play()
    value = value - 1
    local tag = Instance.new("StringValue")
    tag.Name = "tag"
    tag.Value = player.Name
    tag.Parent = otherplayer
    if value <= 0 then
        tool.Handle.BreakingNoise.PlayOnRemove = true
        tool:Destroy()
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

It's because you're not playing the animations. You just loaded them.

Line 08:

    humanoid:LoadAnimation(script.Equip):Play()

Line 10:

    humanoid:LoadAnimation(script.Idle):Play()
0
oh yeah, i forgot about that. Good too know for next time, thanks! 1JBird1 64 — 3y
Ad

Answer this question