New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

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

Asked by
Sir_Melio 221 Moderation Voter
3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

Ad
Log in to vote
0
Answered by 3 years ago
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

Log in to vote
0
Answered by 3 years ago

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()
Log in to vote
0
Answered by
hozann 75
3 years ago

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.

0
Why startergui? If anything, either in a part, or in ServerScriptStorage nathen35 95 — 3y
0
in the startergui, only the person that has the audio in their gui can hear it. hozann 75 — 3y

Answer this question