Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The punching script does not hurt the other player, what should I do?

Asked by
xsodar 19
4 years ago

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?

01local userInputService = game:GetService("UserInputService")
02 
03local PunchValue = false
04local db = false
05local leftPunch = script.LeftPunch
06local rightPunch = script.RightPunch
07wait(0.1)
08 
09local player = game.Players.LocalPlayer
10local char = player.character
11local hum = char.Humanoid
12local leftHand = char.LeftHand
13local rightHand = char.RightHand
14local humanoidRootPart = char.HumanoidRootPart
15 
View all 54 lines...

Thanks, Xsodar

0
Script seems fine, problem might be that since it's on the client the server doesn't detect the health gone down. Try using a remote event to deduct the health. User#32819 0 — 4y
0
I did do that but I got an error, but I will try it again, thanks :) xsodar 19 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

if this is a localscript, Try using RemoteEvent beacuse The damage will not be in the server. And also I recommend you to use

1human:TakeDamage(Damage_Here)

instead of using:

1human.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

Ad

Answer this question