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

Help with Local Sounds?

Asked by 10 years ago

** How would I create a sound that would only play for you when you press a button? or when someone steps on a brick?**

An example of a script would be great, thanks!

Could it possibly have something to do with local bricks, such as a message in a player?

localbin = Instance.new('Message')
localbin.Parent = game.Players.LocalPlayer:WaitForChild('Character').
localbin2 = Instance.new('Sound',  localbin)
localbin2.SoundId = 'soundname'

Also, how would I cause it to play as well? I have no experience in manipulating sound.

0
Just parent the sound to someone's PlayerGui. Perci1 4988 — 10y
0
Use the :Play() method to play audio; localbin2:Play(). There's also :Stop() and :Pause(). Redbullusa 1580 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

From how I'm reading your script, you are attempting to use the WaitForChild method on the Player's Character, you can not do that, for it is not searching for the Player's Physical Character, but something inside LocalPlayer named Character, you are also calling 'localbin' to create Message, yet you are not using it anywhere in the code that I can see, also, you are attempting to change localbin2's SoundId to soundname, it MUST be a Link, because nothing will play otherwise, here is how it would look like;

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
localbin = Instance.new("Message") --What is this used for? :/
localbin.Parent = game.Players.LocalPlayer.Character
localbin2 = Instance.new("Sound",  localbin)
localbin2.SoundId = "http://www.roblox.com/asset/?id=num"

Hope this helped!

0
'Message' Is used for localbricks, but thanks anyways killerkill29 35 — 10y
Ad

Answer this question