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

Sound won't play once child is added?

Asked by 4 years ago
Edited 4 years ago

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.

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 Fifkee 2017 — 4y
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. NoahsRebels 99 — 4y
0
Try this: Sound.Playing = true instead of Sound:Play() MasonJames136 21 — 4y
0
The sound won't be inserted into the torso in the first place. NoahsRebels 99 — 4y

2 answers

Log in to vote
1
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago

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

0
OH RIGHT, thank you mate NoahsRebels 99 — 4y
0
Wait sorry, It's still not adding the sound to the torso. NoahsRebels 99 — 4y
Ad
Log in to vote
0
Answered by
EthanFins 104
4 years ago

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

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. NoahsRebels 99 — 4y

Answer this question