Make a detector block

Hey so:
I was making a card scanner, so I added a normal part to a model, I would like to make that when a specific tool touches that, makes a sound (beep), just a rblx sound.
Hope someone can help me, thanks!

1 Like

Here’s some example code:

local debounce = false

Part.Touched:Connect(function(hit)
if hit.Parent:IsA(“Tool”) and hit.Parent.Name == “toolName” and not debounce then
debounce = true
yourSound:Play()
task.wait(2) -- or whatever
debounce = false
end
end)

Added a debounce so the sound doesn’t spam, someone correct me if I’m wrong.

Hope this helps you out :slight_smile:

1 Like

Soo…
Testing out script and didn’t work, If someone can still help me out with this, It would be great!
Here i leave script:

local debounce = false

Part.Touched:Connect(function(hit)
	if hit.Parent:IsA(“Tool”) and hit.Parent.Name == “Tmobilitat” and not debounce then -- Tmobilitat is the tool
		debounce = true
		beep:Play() -- "beep" is the sound.
		task.wait(2) -- or whatever
		debounce = false
	end
end)
1 Like

try printing ‘hit’ to see what is actually being touched, or add a loop to loop through the character and see if the tool is in their character

2 Likes