Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why aren't my animation's playing?

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

✓ Accepted answer

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()

1 comment

0

oh yeah, i forgot about that. Good too know for next time, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.