This is not a request site, but I will help you get to what you are looking for.
The issue you are experiencing is that FilteringEnabled is preventing you from playing the audio across all clients. To get around this, you must play the sound from the Server.
This is a good article to get started with RemoteEvents. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events
After reading this over, you can do something like this:
SERVER SCRIPT
local Event = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))
Event.Name = "CBAlarmEvent"
local Sound = game:GetService("ReplicatedStorage"):WaitForChild("CBAlarm")
Event.OnServerEvent:Connect(function(Player, OnOff)
if OnOff == true then
Sound:Play() Sound.Looping = true
game.StarterGui.GUI.Main.AlarmsList.ContainmentBreach.TextLabel.Text = "ON"
Event:FireAllClients("ON")
else
Sound:Play() Sound.Looping = false
game.StarterGui.GUI.Main.AlarmsList.ContainmentBreach.TextLabel.Text = "OFF"
Event:FireAllClients("OFF")
end
end)
LOCAL SCRIPT
local localgui = game.Players.LocalPlayer.PlayerGui
script.Parent.MouseButton1Click:Connect(function()
if localgui.GUI.AdminPanel.Text == "!setalarm CB true" then
game.ReplicatedStorage:WaitForChild("CBAlarmEvent"):FireClient(true)
end
if localgui.GUI.AdminPanel.Text == "!setalarm CB false" then
game.ReplicatedStorage:WaitForChild("CBAlarmEvent"):FireClient(false)
end
end)
game.ReplicatedStorage:WaitForChild("CBAlarmEvent").OnClientEvent:Connect(function(Text)
localgui.GUI.Main.AlarmsList.ContainmentBreach.TextLabel.Text = Text
end)
This script could use some work and I suggest you continue looking into the article for more info. I did not make it perfect as I want you to learn (this is not a request site), but it should be functional.
If this helped, mark it correct and upvote. Thanks!
4 comments
Because an action you do on the client won't replicate to other clients. You should use RemoteEvents
remote events needed if you want it be shown to all the other players. :FireServer and stuff like that. https://developer.roblox.com/api-reference/class/RemoteEvent
Could anyone write the whole scripts and tell me where to put those scripts? Please I need helpp.
I'll do it