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)
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.