How do I make a script that plays a sound when you touch the block but the next time you touch the block it doesn't play the sound?
Assuming you know some stuff I wrote this script. So what this does is when a part is touched it will check if it was touched by a player and then play the sound. The script checks if the sound is playing already so it doesn't glitch. Then it waits and destroys the script so it can't run again.
local part = script.Parent --player will touch the parent of this script local sound = script.Parent:WaitForChild("NameOfYourSound") --the sound is inside the part part.Touched:connect(function(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human then if sound.IsPlaying == false then sound:Play() wait(time of sound) script:Destroy() end end end)
Is this it?
local NotTouched = true local Object = (insert part object here) local Sound = (insert sound object here) Object:Touched:connect(function(hit) if hit == game.Players.LocalPlayer.Character.Humanoid and NotTouched then NotTouched = false Sound:Play() end end) Object:TouchEnded:connect(function(hit) if hit == game.Players.LocalPlayer.Character.Humanoid and NotTouched then Sound:Stop() end end)