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

local sword = script.Parent 
--the variable of the sword
local hum = game.Players.LocalPlayer
sword.Touched:Connect(function(hit)--touched event
local zombie = --here you get the npc you have
                           --as an example "local part = 
                              game.workspace
if zombie then
--take from the npc's health
end
if hum then
--take 0 hp from the player when it is hit by the sword
end
end)

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