game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player)
for i,v in pairs(game.Players:GetPlayers())
local ui = -- GUI location
ui:Clone().Parent = v.PlayerGui
end
end)
local Players = game:GetService("Players")
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
for i, player in ipairs(Players:GetPlayers()) do
task.spawn(function()
local PlayerGui = player:WaitForChild("PlayerGui")
PlayerGui.ALERTTOP.TextLabel.Visible = true
task.wait(3)
PlayerGui.ALERTTOP.TextLabel.Visible = false
end)
end
end)
Similarly like what @ dreamyymax said, use remote events. This is one way i’d approach this:
Try adding two remote events in replicated storage.
Then, insert a localscript within the button:
local Appear = script.Parent.Parent.Frame -- The object you want to be appear on all screens
local button = script.Parent -- the textbutton/imagebutton you are going to press on
--events:
local event = game:GetService("ReplicatedStorage").RemoteEvent
local event2 = game:GetService("ReplicatedStorage").RemoteEvent2
button.MouseButton1Click:Connect(function()
event:FireServer()
end)
event2.OnClientEvent:Connect(function()
Appear.Visible = true
end)
Add a script inside serverscriptservice:
local event = game:GetService("ReplicatedStorage").RemoteEvent
local event2 = game:GetService("ReplicatedStorage").RemoteEvent2
event.OnServerEvent:Connect(function(plr)
event2:FireAllClients()
end)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Players.PlayerGui
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent_ToServer = ReplicatedStorage:WaitForChild("Admn1")
local RemoteEvent_ToClient = ReplicatedStorage:WaitForChild("Admn2")
local SpamWait = 2 --How long you want to wait until the button can be pressed again.
local Ran = false
PlayerGui.Admin1.Admin1.ALERT.MouseButton1Click:Connect(function()
if Ran == false then
Ran = true
RemoteEvent_ToServer:FireServer("AlertAll")
wait(SpamWait)
Ran = false
end
end)
--Remote Event detecting the signal from the server to show the UI.
RemoteEvent_ToClient.OnClientEvent:Connect(function(Action,Value)
if Action == "AlertShow" then
PlayerGui.ALERTTOP.TextLabel.Visible = Value
end
end)
Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
--Creates the RemoteEvents that your local script will look for.
local RemoteEvent_ToServer = Instance.new("RemoteEvent")
RemoteEvent_ToServer.Name = "Admn1"
local RemoteEvent_ToClient = RemoteEvent_ToServer:Clone()
RemoteEvent_ToClient.Name = "Admn2"
RemoteEvent_ToServer.Parent = ReplicatedStorage
RemoteEvent_ToClient.Parent = ReplicatedStorage
local Admins = {"t3h1dy",81118123}--Table of admins using username or UserId. Change the table to nil to have no admin check.
--Detects the RemoteEvent fired when the admin pressed the button (to make the ALERTTOP visible to everyone)
RemoteEvent_ToServer.OnServerEvent:Connect(function(Player,Action)
if Action == "AlertAll" and (Admins == nil or table.find(Admins,Player.Name) or table.find(Admins,Player.UserId)) then --Checks if the person really is an admin on the list.
StarterGui.ALERTTOP.TextLabel.Visible = true
RemoteEvent_ToClient:FireAllClients("AlertShow",true)
wait(5)
StarterGui.ALERTTOP.TextLabel.Visible = false
RemoteEvent_ToClient:FireAllClients("AlertShow",false)
end
end)
This might help as an alternative, and can help you as you continue to develop, good luck with your project.