How do I make sound play when a part is touched by a person and not NPC. I have walking npcs walking around and they keep messing up the sound. How would I make it so the sound would only play when a real player touches the part?
local sound = Instance.new("Sound", Workspace)
sound.Pitch = 1
sound.SoundId = "rbxassetid://902587196"
sound.Volume = 1
sound.Looped = false
local playonce = false
script.Parent.Touched:Connect(function()
if not playonce then
playonce = true
sound:play()
end
end)

2 comments
This might be a very bad way and I think there is more complicated and better answers, but I hope this helps! Thanks for reading!
Wow. I never thought of that. That was so smart. Thanks for your help!