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

How do i make it so that when a npc touches an object it kills them after 10 seconds? [closed]

Asked by 5 years ago
Edited 5 years ago

So i am working on this game called survive freddy and i noticed that there is a problem when freddy walks into the office he cant leave and he stays there killing everyone and they have to rejoin a new server to fix it. So i was wandering how do i put a script in the door enteryway where when he touches the part that is in the enteryway it kills him after 10 seconds but it does not kill the players playing the game. Please answer. Thanks!

0
touched event + wait(10) may do the work richboifexekappa 89 — 5y
0
does it only work for npcs? Because i do not want it to work for players. soulgamer123456 -3 — 5y

Closed as Not Constructive by JakyeRU, namespace25, and BlueTaslem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Alphexus 498 Moderation Voter
5 years ago

This should work:

script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "[Your NPC Name]" then
    wait(10)
    hit.Parent:Destroy()
end
end)

But I don't recommend doing it this way. This is just an example. A better way would be to put like a Boolean Value in the NPC and make the touched function find the Boolean value.

0
ok thank you! soulgamer123456 -3 — 5y
Ad