Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I want to make a sound come from a different part. Does anyone know how to fix this?

So basically, I made 2 parts, a button with a click detector, and then a different part with the audio in it. The purpose is to click the click detector with the script, and that should make the other SoundPart with the audio play. This is my code: I thought my coding would make sense but apparently it didn't. Does anyone know how to fix this or improve it?

script.Parent.MouseClick:connect (function(start)
script.Parent.Parent.SoundPart.Audio: Play()
end)

1 comment

0

Could you please provide the specific error you receive because, assuming everything is located in the right spot and named properly, this should run just fine.

1 answer

✓ Accepted answer

To be honest I really don't know what you did. However, this may help or not I don't know.

Try this in a local script.

local click = "This should be the directory to your part's click detector"
local soundFire = "Make a RemoteEvent and place it somewhere in which it can communicate with the server"

local soundBlock = "This should be the directory to your sound object"
local soundID = "place the sound id here"

click.MouseClick:Connect(function()
	soundFire:FireServer(soundBlock,soundID)
end)

Put this in a server script.

local soundFire = "The directory to the RemoteEvent you made"

soundFire.OnServerEvent:Connect(function(plr,SoundBlock,soundID)
	if soundBlock.IsPlaying then
		soundBlock:Stop()
		soundBlock.SoundId = soundID
		soundBlock:Play()
	else
		soundBlock.SoundId = soundID
		soundBlock:Play()
	end
end)

This is basic and should work unless I made a few errors somewhere.

This discussion is preserved as it was. New answers, comments, and votes are closed.