I want to when a player touches an npc it dies
The Npc need to be cloned so there like 20 of them at once
right now they all just kill each other
local Boy = script.parent
local function onPartTouched(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
Boy.Humanoid.Health = 0
Touching the hrp can be hard. Consider changing it to UpperTorso or LowerTorso.
Wait a sec… how can someone touch something in replicated storage? Please show me your explorer, am confused.
Well if nothing happens then either you’re not touching the HumanoidRootPart or It’s not finding your humanoid you should print(humanoid) in the touched function and see if it’s nil when you touch it and print(otherpart) to see what it’s touching or if it’s touching also if you don’t want it to damage other npcs then you should check if the thing it’s touching either has a player so do something like
Also Yeah what he said above I’m not sure how it’s meant to be touching something in rep storage so that could be a issue but I also answered how you can make npcs only damage players
local FoundPlayer = Players:GetPlayerFromCharacter(partParent)
if FoundPlayer then
But his npc is in replicated storage… he should put it in workspace…
Yeah he prob doesn’t understand how the touched event works and used a video so Idk how to help.
Exactly. I don’t see the reason it doesn’t work, making a kill brick is like the basics of basics of basic scripting. The only cases where it doesn’t work is wrong parenting.
Firstly you would need to have something in the workspace to touch instead of it being in replicated storage. Other than that you could add a script to the Model(In this case “Boy”) and check if the Part you want being touched finds a humanoid AND if the touched part parent finds a player from the character using - "Players:GetPlayerFromCharacter(touched.Parent) "
If it finds a player from the model then kill the Model by setting the humanoid of said model to 0
I have it in replicated storage because I need to clone it to make loads of them
Should I put it in workspace?
I have a folder in workspace which has all the spawns of the npc
the script takes from replicated storage and clones it all the spawns
Give me the pic of ur workspace please. Also to prevent lag consider putting them into server storage.
You’re using touched on a dummy which is in replicated storage, and if you clone it to workspace touched won’t register on the clone, as ur technically using touched in rs… so uh just make a script inside the dummy:
if game.Players:GetPlayerFromCharacter(hit.Parent) then
hit.Parent.Humanoid.Health = 0