Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Creating a sound on explosion? Please help!

Asked by 8 years ago
Edited 8 years ago

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!

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

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.

0
Wouldn't it look a bit more cooler if you break the joints of the piano or unanchor its children, and then add it to the Debris service? UltimateRaheem 75 — 8y
0
You could break the joints then add the explosion? and yes use the debris service User#5423 17 — 8y
Ad

Answer this question