So this localscript is supposed to throw a punch animation, and if the punch hit another player it should lose -10 health. The thing is that the animation works okay, but it does not give any damage on the other player. How can I fix this/improve my script?
01 | local userInputService = game:GetService( "UserInputService" ) |
02 |
03 | local PunchValue = false |
04 | local db = false |
05 | local leftPunch = script.LeftPunch |
06 | local rightPunch = script.RightPunch |
07 | wait( 0.1 ) |
08 |
09 | local player = game.Players.LocalPlayer |
10 | local char = player.character |
11 | local hum = char.Humanoid |
12 | local leftHand = char.LeftHand |
13 | local rightHand = char.RightHand |
14 | local humanoidRootPart = char.HumanoidRootPart |
15 |
Thanks, Xsodar
if this is a localscript, Try using RemoteEvent beacuse The damage will not be in the server. And also I recommend you to use
1 | human:TakeDamage(Damage_Here) |
instead of using:
1 | human.Health = human.Health - 10 |
I am not sure if i can make a Complete Script To fix it.
but if you're not sure what RemoteEvents are i suggest you to read this
I hope it atleast give you a little bit of help