Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Sound won't play once child is added?

I was revising the old Rocket Boots from the original SFOTH and was making it so that the sound it plays when used can be heard by everyone near the player vs only the playing using the boots. I made a script that plays a sound once the BodyVelocity is added to the users torso, although it doesn't seem to do anything nor give me any errors, here's the script:


function PlayIfAdded(BV)
	if BV.ClassName == "BodyVelocity" then
		local Sound = Instance.new("Sound",script.Parent.Parent.Torso)
		Sound.SoundId = "rbxasset://sounds\\Rocket whoosh 01.wav"
		Sound.Volume = .75
		Sound.Name = "RocketSound"
		Sound:Play() 
	end
end

function StopIfRemoved(BV2)
	if BV2.ClassName == "BodyVelocity" then
		if script.Parent.Parent.Torso:FindFirstChild("RocketSound") ~= nil then
			script.Parent.Parent.Torso.RocketSound:Destroy()
		end
	end
end

script.Parent.Parent.Torso.ChildAdded:Connect(PlayIfAdded)
script.Parent.Parent.Torso.ChildRemoved:Connect(StopIfRemoved)

Edit: The main problem now is that it won't add the sound to the player's torso.

2nd Edit to explain a bit more:

The rocket boots don't have a handle, and I turned RequiresHandle off. This script I'm showing here is normally disabled, but it gets enabled once you equip the tool, and disabled once you unequip it. The main flying script is local, and this script (as well as the enable/disable script) isn't. Although every other part of the boots work fine, it just won't add the sound to the torso.

4 comments

0

change "rbxasset://sounds\Rocket whoosh 01.wav" to "rbxasset://sounds//Rocket whoosh 01.wav." you're probably escaping the first backslash and that would make the url doodoo

0

Again, the URL works fine, I tested it in studio before playing, the problem is it's not making the new sound and putting it in the torso. I even tried to make an existing sound and clone it into the torso instead but got the same result.

0

Try this: Sound.Playing = true instead of Sound:Play()

0

The sound won't be inserted into the torso in the first place.

2 answers

You never call :Play() on the audio object.

2 comments

0

OH RIGHT, thank you mate

0

Wait sorry, It's still not adding the sound to the torso.

I think what's wrong with your script is the amount of spaces that are in your ID

1 comment

0

It's the exact same ID from the original rocket boots and the ID works fine, it's just that the sound is only heard by the player using the boots. It's not even adding the sound to the torso either way.

This discussion is preserved as it was. New answers, comments, and votes are closed.