I want to implement a multi-attack system for a melee weapon, basically if you just tap the left mouse button you will do a light attack, and if you hold down the left mouse button for, say, a second, it will do a heavy attack. Since I'm using a tool, I would prefer to use tool.Activated, but I'm open to other solutions.
Use the mouse. You can get the mouse by getting the player (in this case it will be the Parent of the tool) and the :GetMouse() function.
local Count = 0 local up = false local player = game.Players:GetPlayerFromCharacter(script.Parent) local mouse = player:GetMouse() mouse.Button1Down:Connect(function() repeat Count = Count + 1 until up = true end) mouse.Button1Up:Connect(function() if Count <= 1 then --short blast code here else --long blast code here end end)
Use MouseButton1Click
for the light attack and for the heavy attack, use MouseButton1Down
as the player would need to hold the left mouse for a heavy attack. Inside the MouseButton1Down
add a wait of (1) or 2 and then write the script for the heavy attack.