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.
01 | local Count = 0 |
02 | local up = false |
03 |
04 |
05 | local player = game.Players:GetPlayerFromCharacter(script.Parent) |
06 | local mouse = player:GetMouse() |
07 | mouse.Button 1 Down:Connect( function () |
08 | repeat |
09 | Count = Count + 1 |
10 | until up = true |
11 | end ) |
12 |
13 | mouse.Button 1 Up:Connect( function () |
14 | if Count < = 1 then |
15 | --short blast code here |
16 | else |
17 | --long blast code here |
18 | end |
19 | 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.