You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
sound on touch of a part but only once of that sound and no more
What is the issue? Include screenshots / videos if possible!
When I touch the part it keeps repeating the noise if I walk all over it but I only want it to play it once
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive looked at youtube videos but they werent clear abt the part im looking for
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
this is the script:
local part = script.Parent
part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
local sound = script.Parent.SonictheHedgehogSFX
if not sound.IsPlaying then
sound:Play()
end
end
end)
local part = script.Parent
local CanPlay = true
part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
if CanPlay == true then
CanPlay = false
local sound = script.Parent.SonictheHedgehogSFX
sound:Play()
task.wait(sound.TimeLength)
CanPlay = true
end
end
end)
that wasnt quite what I was looking for but I solved it with the help of it because the sound is 1 - 2 seconds long it still gave almost the same result so all I did was change the task.wait(sound.TimeLength) to task.wait(100) which just makes it takes 100 seconds before u can go and repeat it again but I wanna know a way to make that 100 second into like infinite I guess basically just not letting them play the noise at all after the first time.
local part = script.Parent
local CanPlay = true
part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
if CanPlay == true then
CanPlay = false
local sound = script.Parent.SonictheHedgehogSFX
sound:Play()
end
end
end)
local part = script.Parent
local debounce = false
part.Touched:Connect(function(Hit)
if debounce == false then -- if its true it wont get trough this
debounce = true
if Hit.Parent:FindFirstChild("Humanoid") == true then
local sound = script.Parent.SonictheHedgehogSFX
sound:Play()
debounce = false -- here it sets the debounce back to false so it can work again
end
end
end)