Hello I have a surface gui that I'm trying to make activate a screengui with custom text to everyone on the server.
I have this so far
function leftClick() game.StarterGui.EASGui.Frame.ALERT.Text = script.script.Parent.Parent.TextBox.Text script.Parent.Parent.TextBox.Text = "" wait(3) game.StarterGui.EASGui.Frame.Sound.Playing = true game.StarterGui.EASGui.Enabled = true wait(30) game.StarterGui.EASGui.Enabled = false end script.Parent.MouseButton1Click:Connect(leftClick)
for the localscript under my textbutton
BTW: Keep in mind that I'm trying to activate the GUI for the ENTIRE server.
To begin, you can't use a LocalScript to change everyone's screen without using a RemoteEvent.
Second, if you change "StarterGui" it won't have any effect, it has to be the PlayerGui, which is a child of each individual player.
To start, put a RemoteEvent in ReplicatedStorage and name it "AlertEvent".
Next, inside your button put a LocalScript and write this.
local event = game:GetService("ReplicatedStorage"):WaitForChild("AlertEvent") script.Parent.MouseButton1Click:Connect(function() local textToSend = script.Parent.Parent.Parent.TextBox event:FireServer(textToSend.Text) end)
This will send arguments to the server, where we will change everyones screen, the first argument will always be the player firing the event, and then any arguments afterwards. For this example, our only argument will be the text that we want to alert.
After that, put a ServerScript inside of ServerScriptService and write this.
local event = game:GetService("ReplicatedStorage"):WaitForChild("AlertEvent") event.OnServerEvent:Connect(function(plr,text) for _,player in pairs(game:GetService("Players"):GetChildren()) do player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Frame.ALERT.Text = text wait(3) player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Frame.Sound:Play() player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Enabled = true wait(30) player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Enabled = false end end)
This will receive the player who fired the event, and the text we want to change. It will also loop through every player's gui and change the text, play the sound, make it visible, wait 30 seconds, and then not make it visible.
Hope this helped!
If this worked for you, let me know by selecting this as the answer!
If it didn't work, comment down below what went wrong and I'll try to help.