How to make playback louder closer you are to a model

So im not the best scripter when it comes to maths lol i want to increase a sounds playerback the closer you are to a model. and if your far away the playback will be set to 0

3 Likes

Hi @Tunnells

You Can use PlaybackLoudness

1 Like

I know im saying how would i increase it depending on the player distance

1 Like

Use Sound | Roblox Creator Documentation and Sound | Roblox Creator Documentation.

I sound playback increases when near something

Did you read the links?
This is exactly what these Properties are for.
The MinDistance Value that you set is that the volume is going to be max at that distance in studs and is going to RollOff to the MaxDistance value in studs that you set.
You can also change the Sound | Roblox Creator Documentation to change how the volume decreases.

i think he wants to do it manually soo he can know how loud the sound is for the player for horror game purposes

1 Like

i want to do what @BielNS says

That’s what those values do.
If you set Sound.RollOffMinDistance to 0 it will be full volume at the SoundEmitter source.
If you want it to be quiet at 10 studs away you set Sound.RollOffMaxDistance to 10 (studs).
You can change RollOffMode to make it completely silent at the MaxDistance, or fade out gradually.
It’s all explained in the links.

as Scottifly already said multiple times: RollOffMaxDistance and RollOffMinDistance already does what u want, but incase u still want to do it manually here it is:

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local run = game:GetService("RunService")

local part = workspace.abc
local sound = workspace.abc.Sound

-- configs
maxdist = 100

run.RenderStepped:Connect(function()
-- remove roblox default sound distance thing
sound.RollOffMaxDistance = 100
sound.RollOffMinDistance = 100

-- apply our default one
local dist = math.clamp((hrp.Position-part.Position).Magnitude,0,maxdist)
local far = (dist/maxdist) -- use this if u want the sound to be louder the more distant the player is from the sound
local close = 1-far -- use this if u want the sound to be louder the closer the player is to the sound

sound.Volume = close
end)

I said not volume :confused: Playback as in the speed of the song increase not volume

OOOOOOOOOOOOOOOOOOOHHHHHHHHHHHHHHHHHHH, i see i see

1 Like

here

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local run = game:GetService("RunService")

local part = workspace.abc -- put the part here
local sound = workspace.abc.Sound -- put the sound here

run.RenderStepped:Connect(function()
local maxdist = sound.RollOffMaxDistance
local dist = math.clamp((hrp.Position-part.Position).Magnitude,0,maxdist)
local far = (dist/maxdist) -- low pitch when close, high pitch when far
local close = 1-far -- high pitch when close, low pitch when far

sound.PlaybackSpeed = close
end)
2 Likes