#how to make the server hear the audio when a player clicks the button im noob
1 messages · Page 1 of 1 (latest)
ye
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
wdym?
like if u click the button the audio will play but if u click it again it will pause it
** You are now Level 1! **
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
sorry, I got side tracked.
Use a click detector
When triggered, play the sound
it's a gui
done
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
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
alr
i paste it in the serverscript
sure
just make sure to change ur variables