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

How do you make a sound play on one place only?

For example, a sound is playing, everyone can hear it, but I want it to play in a player's humanoid or torso so it has a distance til you can't hear it.

4 answers

✓ Accepted answer

oh god, everyone above knows nothing about sounds. here is an example of a sounds properties. Sound Properties The MaxDistance is the thing we need to look . If you put a sound Instance in a object which has a vector3 position then setting the max distance to something like .. 5 or 10 will do the trick so ..

--This is in a local script
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character and plr.Character.Torso
local sound = Instance.new("Sound", plr.Character.Torso)
sound.SoundId = "http://www.roblox.com/asset/?id=" -- id of music
sound.MaxDistance = 10 -- Distance

Lastly place the local script in starterplayerscripts

local player = game.Players.LocalPlayer
local playername = player.Name

local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=" --Your ID here
sound.Parent = game.Workspace[playername].Torso

What this does is make a variable for the localplayer, and then make a variable for the name of the player. And then it creates a new sound instance, and put in your own ID, and finally, it looks in Workspace for the playername and places it in the torso

It would be easier to just put the sound into a part. You wouldn't be able to hear it if you're too far away, but the only downside is that everyone would hear it if they got in range to it.

local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=" --Id to music goes here
sound.Parent = script.Parent -- Please make sure this script is in a Part!
sound:Play()

If you want to just have them hear it from wherever they are, try putting your audio or code in 'startergui' or the person's gui, by going to Players.(theirname).PlayerGui and then insert it into there.

2 comments

0

Why startergui? If anything, either in a part, or in ServerScriptStorage

0

in the startergui, only the person that has the audio in their gui can hear it.

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