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

How do I make a sword not be able to kill players?

Asked by 5 years ago

Let me go into more detail. I have the classic ROBLOX sword in StarterPack and I want to make it so it can only hit zombies but not other players. Is this possible? All help is appreciated.

1 answer

Log in to vote
0
Answered by
seikkatsu 110
5 years ago

you just have to add an if statement in the roblox sword that looks something like this

01local sword = script.Parent
02--the variable of the sword
03local hum = game.Players.LocalPlayer
04sword.Touched:Connect(function(hit)--touched event
05local zombie = --here you get the npc you have
06                           --as an example "local part =
07                              game.workspace
08if zombie then
09--take from the npc's health
10end
11if hum then
12--take 0 hp from the player when it is hit by the sword
13end
14end)

If you found my answer helpful please consider hitting that accept answer button and hit me up if you need any more help.Have a nice day!

0
sorry i wrote it on mobile seikkatsu 110 — 5y
0
Thanks! This works! matiss112233 258 — 5y
0
happy to help! seikkatsu 110 — 5y
Ad

Answer this question