01 | local player = game.Players.LocalPlayer |
02 | mouse = player:GetMouse() |
03 |
04 | local damage = 5 |
05 |
06 |
07 | function leftpunch() |
08 | local leftpunch = player:findFirstChild( "Left Arm" ) |
09 | leftpunch.Position.Vector 3. new( 30.422 , 179.001 , 138.099 ) |
10 | leftpunch.Rotation.Vector 3. new( 90.161 , 17.144 , - 53.438 ) |
11 | wait( 1 ) |
12 | leftpunch.Position.Vector 3. new( 37.5 , 179.8 , 146.003 ) |
13 | leftpunch.Rotation.Vector 3. new( 179.669 , - 0 , 180 ) |
14 | end |
15 |
When you press z, you left punch, But it's not working. Why? Can you explain why too?
put it into 1 function
01 | function KeyDown(key) |
02 | key:lower() |
03 | if key = = 'z' then |
04 | --watever arm movements here |
05 | leftpunch.Touched:connect( function (hit) |
06 | h = hit.Parent:FindFirstChild( 'Humandoid' ) |
07 | if h ~ = nil then |
08 | h:TakeDamage(damage) |
09 | elseif hit.Parent.Name = = leftpunch.Parent.Name then |
10 | print ( 'Player cannot Punch himself' ) |
11 | end |
12 | end |
13 | end |
14 | end |
15 |
16 | mouse.KeyDown:connect(KeyDown) |
mouse is not an event. You need to do
1 | local mouse = game.Players.LocalPlayer:GetMouse(); |
2 | mouse.KeyDown:connect( function (key) |
3 | --key code |
4 | end ) |