I am trying to make a zone where when an NPC named “Ghost” walks into a part that is non-colidable, the NPC will turn invisible by this code:
if hit.Parent.Name == "Ghost" then hit.Parent.Agro.Value = true for i,v in pairs(hit.Parent:GetDescendants()) do -- loop through everything in the character if v:IsA("BasePart") or v:IsA("Decal") then -- if it is a part v.Transparency = 1 -- make it invisible end end end
What’s the issue?
The problem is that the code I used which was when touched and when touched ended, the script would constantly make the NPC invisible and then visible.
Is there a way to detect when an NPC is inside of part without using when touched and when touched ended?