This is probably a simple problem and I’m just not seeing it! The sound is not playing when I run this script, how do I fix that? It runs if I place it outside the function but I want it to run when the player steps on it. Maybe I didn’t define it properly? Thanks! God bless.
game.Workspace.Part.GlassShatter.Enabled = false
local Part = script.Parent
local sound = Instance.new("Sound", game.Workspace.Part)
sound.SoundId = "rbxassetid://5183344180"
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
Part.Transparency = 1
Part.CanCollide = false
wait()
Part.GlassShatter.Enabled = true
Part.GlassShatter.Rate = 100
Part.GlassShatter.Life = NumberRange.new(1,1) --stack ends here
wait()
sound:Play()
Part.GlassShatter.Enabled = false
end
end)
The thing is it loads fine when I place it outside my function when the function runs, but I need to be inside the function and it won’t play any sound when I do that.
Perhaps making an external modual script for sound managment might allow it to play, not worked with sounds since the revamp but if its loaded then it should be able to play even within functions.
Also make sure to check if the conditions are met for you if statement, just add a print in the while its in testing
Alright, so I placed it at the top inside the function and it runs. It does keep trying to repeat the sound and it sounds glitchy lol. How do I debounce it, or make it only play once?