Make Sound play after a certain distance away from origin part

Hello, I’m trying to make a sound start playing only after a certain distance away from a sound part. I’ve tried messing with RollOff Distances and I cant quite seem to figure it out. Does anybody have any idea on how I can achieve this goal?

Here is a quick image representation of what I mean, as it is a bit hard to explain in text.
image

1 Like

So um, try a LocalScript:
StarterPlayerScripts

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

Part = workspace.Part
YourSound = Part.YourSound -- Replace with the sound you want to use

MaxDistance = 10
SoundHeard = true

while true do
task.wait()
local Mag = (Char.HumanoidRootPart.Position - Part.Position).Magnitude
if Mag < MaxDistance and SoundHeard == true then
 YourSound:Stop() 
SoundHeard = false
else
SoundHeard = true
YourSound:Play()
end
end

You can pretty much do that in the sound itself.

-- Local Script

local RunService = game:GetService('RunService')
local Plr = game:GetService('Players').LocalPlayer
local Sound = workspace.Sound
local Part = workspace.Part
local Range = 34 -- got 34 by counting the studs in the picture

Sound:Play()

RunService.RenderStepped:Connect(function()
    if Plr:DistanceFromCharacter(Part.Position) > Range then
        Sound.Volume = .5
    else
        Sound.Volume = 0
    end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.