Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

3 comments

0

sorry i wrote it on mobile

0

Thanks! This works!

0

happy to help!

This discussion is preserved as it was. New answers, comments, and votes are closed.