function onclick(Player) local Part = game.Workspace.Part Instance.new("Sound",Part) game.Workspace.Part.Sound.SoundId= "274504661" game.Workspace.Part.Sound:Play() game.Workspace.Part.Sound.Looped = true game.Workspace.Part.Sound.Volume = 1 end game.Workspace.Part.ClickDetector.MouseClick:connect(onclick)
It keeps saying sound failed to load. Also, how would I make it so you can only click the brick once and then it stops letting the player click it?
When entering a sound ID, you need either rbxassetid://
or http://www.roblox.com/asset?id=
as a prefix of the ID. Your code would need to be:
function onclick(Player) local Part = game.Workspace.Part Instance.new("Sound",Part) game.Workspace.Part.Sound.SoundId= "rbxassetid://274504661" -- Added the prefix game.Workspace.Part.Sound:Play() game.Workspace.Part.Sound.Looped = true game.Workspace.Part.Sound.Volume = 1 end game.Workspace.Part.ClickDetector.MouseClick:connect(onclick)
He is correct. You need the prefix for your sound Id. But you could also make your code a bit simpler.
function onclick(Player) local Part = game.Workspace.Part Instance.new("Sound",Part) game.Workspace.Part.Sound.SoundId= "rbxassetid://274504661" Part.Sound:Play() Part.Sound.Looped = true Part.Sound.Volume = 1 end game.Workspace.Part.ClickDetector.MouseClick:connect(onclick)
You can get rid of the game.workspace because you locally defined Part as being at game.workspace so it will refer to your localized location and know that Part is in game.workspace.