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

Make NPC have different states?

Asked by 4 years ago

I want to make an NPC have different states, but now I'm stuck It is in a touch function but how do I detect if it's been touched for a second time?

Code:

local hum = script.Parent.Guard.Humanoid
local GN = script.Parent.Guard
local Ac = GN.Head.Ac.A -- Billboards guis text

--DET = Detection Part
script.Parent.Guard.DET.Touched:Connect(function(hit)
if hit.Parent.Name == "Gun" then -- Testing if the tool your holding is in the area  (The tool is auto equipped)                   


hum:MoveTo(hit.Position)-- Finds your last position and moves to it.

script.Parent.Value.Value = false -- Tells Walking script to stop walking Around different points.
Ac.Text = "?"


wait(3)

---I want it to detect again to see if they can still see the player.


Ac.Text = " "
script.Parent.Value.Value = true-- Goes back to walking.
end
end)

How would I go about this?

Answer this question