How would I script this so whenever I punch it will damage the player?
Asked by
5 years ago Edited 5 years ago
I have a punch script in a local script and server script.
I use local script to detect when he punches, create a cool down and play an animation.
The server is used to damage the punched player.
How would I make it work? Im really new to combat systems and damaging the humanoid.. please help me..
Local script:
01 | local AnimPunch = Instance.new( "Animation" , Character) |
03 | local PunchAnim = Humanoid:LoadAnimation(AnimPunch) |
07 | UIS.InputBegan:Connect( function (k) |
08 | if k.KeyCode = = Enum.KeyCode.F and Pressed = = false then |
11 | punchEvent:FireServer() |
Server script:
02 | local char = p.CharacterAdded:Wait() |
04 | local hit = char.RightArm |
06 | local hum = hit.Parent:FindFirstChild( "Humanoid" ) |
13 | punchEvent.OnServerEvent:Connect( function (p) |