Hello! I am making a funny little game where it's raining pianos. I can make a sound instance, but I can't set an id for the sound, and then play it. I can't find any articles related to this, even on the forum. here is the script for the piano:
local piano = script.Parent wait(3) local explosion = Instance.new("Explosion", game.Workspace) explosion.Position = piano.Position wait(0.2) piano:Destroy() --Wafflesandwich1
Thanks for any help!
The sound id needs to be in the following format (protocol)://(string)
as this tells roblox how to get the sound, the most commonly used format is rbxassetid://(asset id)
. Other content formats and additional information can be found here
You can set the sound id in studio by inputting the id next to the sound id box and studio should format this id into the correct format as shown above. We are also able to test the sound in studio.
It is also possible to add it to your script:-
local piano = script.Parent wait(3) local sound = Instance.new("Sound") sound.SoundId = 'rbxassetid://' -- some sound id here local explosion = Instance.new("Explosion") explosion.Position = piano.Position -- it is best to set the parent last sound.Parent = piano explosion.Parent = game.Workspace sound:Play() -- play the sound wait(0.2) piano:Destroy()
I hope this helps.