How would I make the sound become louder with magnitude?

local player = game:GetService(“Players”).LocalPlayer

local sound = script:WaitForChild(“Sound”)

local runService = game:GetService(“RunService”)

local farmer = workspace.Farmer.HumanoidRootPart

runService.RenderStepped:Connect(function()
farmer.PointLight.Enabled = true
local magnitude = (farmer.Position - player.Character.Head.Position).Magnitude
if magnitude <= 40 then
sound:Play()
elseif magnitude > 40 then
sound:Stop()
end
end)

I would I make it become louder when the player comes near to the farmer?

1 Like

Try parenting the sound to the farmer. I believe Roblox does the job for you. It changes the sound based upon distance.

1 Like

Can’t you just set the RollOffMinDistance & RollOffMaxDistance properties to set how loud you want the sound to be depending on where you are instead?

1 Like

yes but someone is controlling the farmer and i want the sound to be local to the player going near him and also not that the farmer can hear the sound.