So I'm fairly sure I know how to make the sound play when a player clicks a brick. I think it would be a brick with a click detector in it, and then the script would be:
script.Parent:Play()
At least I think so. But the real problem, is how would I make it so only the player who clicked it heard the sound? Would I just put the sound in the PlayerGui? Or would it be something different?
[Edit] I'm using:
script.Parent:Play()
Would I use:
script.Parent:Play(NameOfSound)
? Or do I need a whole new code, cause if so I have no idea what it would be.
Yes, just place the sound in the PlayerGui, that will make it play locally.
Thanks to the use of Click Detectors! You can create a sound object within a brick and send it into the Player's PlayerGui to play the sound.
-- 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)
Try playing local sounds.
To do this, you insert the sound object in the player's playergui, so sounds aren't played globally.
um i may not be a good scripter buttPlayer.PlayerGui:findFirstChild("ClickAudio") then 05 local ls = Instance.new("Sound") 06 local length = 1 -- How long the sound plays before removed. 07
08 ls.SoundId = "http://www.roblox.com/asset/?id=" -- Audio id here. 09 ls.Name = "ClickAudio" 10 ls.Volume = 0.5 11 ls.Pitch = 1 12 ls.Parent = Player.PlayerGui 13 ls:Play() 14
15 game:GetService("Debris"):AddItem(ls, length) 16 end 17 end 18 script.Parent.MouseClick:connect(onMouseClick) there