Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a sound play only once when Touched???

This is really confusing as I only need it to play Once, but whenever I collide, it replays the sound.

Here's What I have so far:

local Sound = script.Parent.Sound
local Set = false

function onTouched(hit)
	if Set == false then
		Sound:Play()
	elseif Set == true then
		Sound:Stop()
	wait(3)
	Sound:Stop()
	Set = true
	

Help is Greatly appreciated.

1 answer

✓ Accepted answer

This assumes you have a part in workspace with this script inside it:

local Sound = script.Parent.Sound
local Set = false

script.Parent.Touched:Connect(function(part)
   if not Set then
      Set = true
      Sound:Play()
      wait(3)
      Sound:Stop()
      Set = false
   else
      Sound:Stop()
      Set = false
   end
end)

1 comment

1

-1 for not explaining your solution.

This discussion is preserved as it was. New answers, comments, and votes are closed.