#how to make the server hear the audio when a player clicks the button im noob

1 messages · Page 1 of 1 (latest)

copper sun
#

@solemn swift still need help?

solemn swift
#

ye

copper sun
#

okay so

#

put a local script and the sound inside the button and do this

#
local sound = script.parent.sound
local button = script.parent

button.MouseButton1Click:Connect(function()
sound:Play()
end)
#

that should work

solemn swift
#

alr

#

but you can pause it too

copper sun
solemn swift
#

like if u click the button the audio will play but if u click it again it will pause it

topaz yachtBOT
#

studio** You are now Level 1! **studio

spice viper
#

use a boolean to keep track of whether or not its playing

#

when its not playing set playing to true and then play the sound

#

when it is playing set playing to false and pause the sound

#

ex:
local playing = false

if not playing then
playing = true
sound:Play()
else
playing = false
sound:Pause()
end

low harness
#

this is all local btw

#

If u want everyone to hear it

#

Get a "Script"

low harness
#

Use a click detector

When triggered, play the sound

solemn swift
low harness
#

to send it to the server

solemn swift
#

done

low harness
#

yeah but you gotta use code on a normal script to handle that remote event activation

#

like you can keep track if ur sound is playing on the client

#

and just send it thru the remote event the value

#

If its true (playing) then it will stop it

#

if its false it will start it

solemn swift
#

alr

#

got it

low harness
#

I can help u with the script but im on mobile so it might take me a bit

#

LocalScript:

local player = game.Players.LocalPlayer
local GUI = player.PlayerGui.yourzUInamehere
local button = GUI.button
local event = game.ReplicatedStorage.SoundEvent
local isActive = false

button.MouseButton1Up:Connect(function()
event:FireServer(isActive)
isActive = not isActive
end)

#

Script:

local Sound = workspace.Sound
local Remote = game.ReplicatedStorage.SoundEvent

Remote.OnServerEvent:Connect(function(Boolean)
if Boolean then
Sound:Play()
else 
Sound:Stop() -- or :Pause() idk
end

end)
#

@solemn swift

solemn swift
#

alr

solemn swift
low harness
#

just make sure to change ur variables