So I have this script put into bricks so that when they are clicked, a sound will play. The problem is, it only works sometimes, at random intervals.
-- This script goes into a ClickDetector within a part. local function onMouseClick(Player) if not Player.PlayerGui:findFirstChild("ClickAudio") then local ls = Instance.new("Sound") local length = 1 -- How long the sound plays before removed. ls.SoundId = "http://www.roblox.com/asset/?id=" -- Audio id here. ls.Name = "ClickAudio" ls.Volume = 0.5 ls.Pitch = 1 ls.Parent = Player.PlayerGui ls:Play() game:GetService("Debris"):AddItem(ls, length) end end script.Parent.MouseClick:connect(onMouseClick)
The audio will play, but not all of the time. And I can't just spam the button a bunch of times, because it won't play. I have to wait a few minutes and try again, and it still might not work.
-- This script goes into a ClickDetector within a part. local function onMouseClick(Player) if not Player.PlayerGui:findFirstChild("ClickAudio") then local ls = Instance.new("Sound") local length = 100 -- How long the sound plays before removed. ls.SoundId = "http://www.roblox.com/asset/?id=" -- Audio id here. ls.Name = "ClickAudio" ls.Volume = 1 ls.Pitch = 1 ls.Parent = Player.PlayerGui ls:Play() game:GetService("Debris"):AddItem(ls, length) end end script.Parent.MouseClick:connect(onMouseClick)
This Should work!
Do you even have your audio id in the script. It's also recommended to have the volume at 1, roblox glitches sometimes.
Lmao Free Modeled You can tell cause he didn't put the 'ID'.