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

My sword script's animations not working?

Asked by
JoneXI 51
4 years ago

Hello, Im new at scripting and I need some help. So, I have a sword script and the damage works fine, but the animations... When I equip the sword the idle animation one hand does what have to do but the other stays default, after I click the attack animation works and my hands make idle animation normally. When I unequip the Sword my hands stuck in Idle animation. I also get an error: "Humanoid is not a valid member of Backpack" I also used this video to make the swords handle cause I dont have tool grip editor... https://www.youtube.com/watch?v=dRGEAethTGA

Script:

script.Parent.Blade.Touched:Connect(function(p)

if script.Parent.CanDamage.Value == true then

script.Parent.CanDamage.Value = false

p.Parent.Humanoid:TakeDamage(20)

end

end)

LocalScript:



local canAttack = true script.Parent.Equipped:Connect(function() local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) idle:Play() end) script.Parent.Unequipped:Connect(function() local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) idle:Stop() end) script.Parent.Activated:Connect(function() local attack= script.Parent.Parent.Humanoid:LoadAnimation(script.Attack) local idle= script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) if canAttack == true then attack:Play() idle:Stop() canAttack = false wait(1) attack:Stop() idle:Play() canAttack = true script.Parent.CanDamage.Value = true end end)
0
use game.Players.LocalPlayer.Character instead of script.Parent.Parent, it's more convenient and more obvious DeceptiveCaster 3761 — 4y
0
You need to load the animation once, you don't need to load it each time an event is called Time_URSS 146 — 4y
0
So I load the animations as a variable? JoneXI 51 — 4y

Answer this question