Can hear Audio from anywhere

Is it giving any errors? I’d also check if the script is in the right spot (inside coinclone).

No. It doesn’t give any errors. And obviously, the script is in the right spot.

Weird. If you send me the coinclone model I can probably debug it.

Coin.rbxl (44.2 KB)
tell me if that worked

It looks like it doesn’t have the correct script inside it:

local audio = script.Parent

local tweenService = game:GetService("TweenService")
local X = script.Parent.Position.X
local Z = script.Parent.Position.Z

local Properties = {
	Position = Vector3.new(X, -0.027, Z)
}
local speed = 1

local TweenInfoo = TweenInfo.new(speed,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out)
local tween = tweenService:Create(script.Parent,TweenInfoo,Properties)

wait()
tween:Play()

Cause I removed it, you can just add a script and put

local coinclone = script.Parent
coinclone.Touched:Connect(function(HIT)
	script.Parent.Sound:Play()
	print("test")
end)

in it.
That script that is in it isn’t irrelevant for this post, it’s just for the coin spawning system script in serverscriptservice which clones the coin ofc. it just gives it a cool tween when it drops. you can remove it if you want :slight_smile:

1 Like

I tested that and it worked. It did play the sound every time the Touched event fires, so I would change the script to:

local coinclone = script.Parent
local connection 
connection = coinclone.Touched:Connect(function(hit)
	if hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then
		script.Parent.Sound:Play()
		print("test")
		connection:Disconnect()
	end
end)

If adding that inside a script doesn’t work, place this code inside the code to debug it:

print("Code is running")

local coinclone = script.Parent
local connection 
connection = coinclone.Touched:Connect(function(hit)
	if hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then
		script.Parent.Sound:Play()
		print("test")
		connection:Disconnect()
	end
end)

if script:IsA("LocalScript") then
	print("Should be a Script, not a LocalScript")
elseif not script:IsDescendantOf(game.Workspace) then
	print("Not in workspace!")
elseif script.Parent.Name ~= "Coins2" then
	print("Parent should be Coins2 but is "..script.Parent.Name)
elseif not script.Parent.CanTouch then
	print("Set CanTouch to true")
end


Well the first script didn’t work, and when I try the second that goes red.

Whoops! Add a space between not and script.

It still seems to not play the sound, and it does say the code is running.

1 Like

That’s really weird. That means the Touched event isn’t firing, but the script is in the right spot and CanTouch is true. Are you using collision groups?

Collision groups filter collisions between set “groups”. You probably haven’t created any. I’m really not sure why it isn’t working.

What do you mean by Collision groups?

It’s in the right spot
image
It all gets cloned into workspace

1 Like

I think you cant do ._OTHERSFX try `:WaitForChild("_OTHERSFX")

Also, you can either play a sound in workspace, or someones camera if local script (there might be other places that I don’t know of)

That doesn’t have to with anything in my case. The issue is that I can hear it from anywhere. Not that.

OHHHHH, I thought you were trying to do that. Alright, will edit the post after I gather my research

Mind making a place file, also make sure you set the position of the part before you play the sound.

1 Like

I have already listed stuff above. Please check those messages before anything else.

Sorry, I haven’t slept in days. Do you notice that this is underlined red?

Not useful

“notscript” is not defined, i’ll go check the messages

Alright, read all messages. Checking the place.

That has already been solved. He forgot to put a space.

Are you still trying to debug the issue?