I didn't think this would work, but I don't know any other way... How can i get it to play the animation when it is swung? Here is my script
function onEquip() local animation = script.Slash print("loading") local plyr = script.Parent.Parent.Parent.Name print(plyr) local char = workspace[plyr] local anim = char.Humanoid:LoadAnimation(animation) print("loaded") function onSwing() print("swinging") anim:Play() end print("swung") end script.Parent.Equipped:connect(onEquip) script.Parent.MouseButton1Down:connect(onSwing)
MouseButton1Down is not a valid member of Tool Please help!!! Thank you!!!
script.Parent.Parent
is Backpack and not the tool. The Backpack doesn't click.
MouseClick
is also an event for ClickDetectors only. Mouse.Button1Down
is for tools.
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() end) end)
MouseButton1Down
is a Mouse
event, you can access the mouse through the onEquip
Function.
function onEquip(mouse) local animation = script.Slash print("loading") local plyr = script.Parent.Parent.Parent.Name print(plyr) local char = workspace[plyr] local anim = char.Humanoid:LoadAnimation(animation) print("loaded") function onSwing() print("swinging") anim:Play() end print("swung") end script.Parent.Equipped:connect(onEquip) mouse.MouseButton1Down:connect(onSwing)