Tool audio playing for the entire server instead of stopping at a distance

Hey, so I’m trying to get this audio inside my tool to play and then cut off in a distance, but considering its directly under the tool and not inside neither base-part or attachment it plays for the entire server.

I’ve tried to put the audio inside the base-part with the script but it won’t play when that’s the case for some reason, i’ve also tried to configure the rolloff function but that only works if it’s inside either base-part or attachment. Am I doing something wrong? Any help is appreciated, thanks.
59ff926adab15a0785f621945874e1ea

Can you send the audio player script?

Here is the script.

local a = false

    script.Parent.Activated:Connect(function()
    	if not a then
    		a = true
    		script.Parent.boom:Play()
    		wait(30)
    		a = false
    	end
    end)

Well there’s your problem. It does nothing about distances, and it’s a serverscript, not a local script. You’d need to make it with a Region3.

If you don’t mind me asking, what is Region3?

Region3 is a data type that describes a volume in 3D space

Region3 - Roblox

You can use this to describe how far/distance you want the music to play.

Thanks, I will attempt to try this.

1 Like

Im so confused. I have no idea how to use Region3.

The issue is that the Sound Object is not parented to a BasePart object of some sort

Put it inside the Handle instead, otherwise the Sound would play globally to everyone that can hear it

The script wont play the audio inside the handle (it will try to run the line to play the audio when LMB is clicked but it wont run the audio), nor will it play if you put the audio inside the handle under the script.

I believe the property you’re looking for would be entailed here:

https://developer.roblox.com/en-us/api-reference/property/Sound/RollOffMaxDistance

No, because it has to be parented with said Brick or Attachment to be able to use it. As far as I know at least; I could be wrong.

Ah… I see.

So you’re handling the audio within a service, instead?

thats because you need to update the line of code that plays the audio so that the script can find the proper location of the audio. Putting it under the handle is fine but you need to update that line of code so that it works. Like this:

script.Parent.Handle.boom:Play()

Then you can play with the rolloff min and max distance so that it cuts off at your preferred distance
(Also, some people are saying you need Region3 but u really don’t. Its very complicated to use that and it could work but it is just too advanced for what ur trying to achieve)

2 Likes

The audio is inside the tool with the script. Otherwise the script wont find the audio and then it wont work for some reason.

I tried to do this yesterday, the code will run, but it is unable to find the audio to play even though it is right there. This is the same if the script is outside the Handle or inside.

There is no error message, but it just does not play. What i’m trying to say.

I’d highly suggest parenting this to a handle, even if it doesn’t have one, you need to give it either an attachment or handle, otherwise it’ll be globally playing.

1 Like

I have already tried that, maybe I am doing something wrong.