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.
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.