I'm making an military game, mostly including NPCs. Every NPC has a binded bool value called "shooting", that sets on "true" when NPC is shooting, and turns "false" when NPC stops shooting.
My goal is to detect if NPC isn't shooting for, let's say, 5 seconds. Script can detect that by reading "shooting" value, but I don't know how would I detect that it doesn't change. That's what I achieved so far, but it doesn't really work.
local debouce = false
local value, changed = nil, false
script.Value.Changed:Connect(function(newValue)
changed = true
value = newValue
wait(5)
if newValue == value and changed == false then
print("Not changing!")
end
changed = false
end)
Thanks in advance!
Krzysiek

1 comment
hmm let me think my son...