Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)
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. XxTrueDemonxX 362 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

Ad

Answer this question