I have made a script that will check if the object that touched it is called "NPC1" or "NPC2" and then delete it.
Script:
function onTouch(hit) local hum = hit.Parent.Humanoid print (hit.Parent.Name) if hit.Parent.Name == "NPC1" or "NPC2" then hit.Parent:Destroy() game.Workspace.Touch.NPCSpawned.Value = false end end script.Parent.Touched:Connect(onTouch)
But if I walk my character onto the block, it deletes my character and anyone else. The print I added was to check if the the block is getting the right object touching it and it is. I also previously tried adding a check for humanoid if statement but that didn't work.
Hello, narrowricky!
function onTouch(hit) local hum = hit.Parent.Humanoid print (hit.Parent.Name) if hit.Parent.Name == "NPC1" or hit.Parent.Name =="NPC2" then --You have to aways give the condition hit.Parent:Destroy() game.Workspace.Touch.NPCSpawned.Value = false end end script.Parent.Touched:Connect(onTouch)
Good Luck with your games