How to rewrite/remake script?

I need to rewrite the script so that when you click on the button on SurfaceGUI, All players will see the game interface located in StarterGui in the disabled format

  • script
local Players = game.Players.AllPlayers
local CountDown = script.Parent.Parent.CountDown
local Notification = game.StarterGui.Notification.NotificationFrame

script.Parent.MouseButton1Click:Connect(function()
	
    Notification.Visible = true
	CountDown.Visible = true

	task.wait(0.10)
	for i=10,1,-1 do
		CountDown.Text = i
		task.wait(1)
	end

	CountDown.Text = ""
	CountDown.Visible = false
	Notification.Enabled = false
end)

  • Screenshots
    Снимок экрана (13884)
    Снимок экрана (13886)

sorry i misunderstood, my answer was wrong so i deleted it.

But doesn’t the contents StarterGui get cloned to each player’s PlayerGui? So wouldn’t we have to to this in player.PlayerGui instead?

Hi there, I hope you’re well. Like oli3omr said, you’ll need to use a RemoteEvent to fire a function to all of the clients (everyone in the game).

Something like this:

Server Script inside the SurfaceGui:

local Button = script.Parent.TextButton --  Text button
local ReplicatedStorage = game:GetService("ReplicatedStorage") --  ReplicatedStorage
local RemoteEvent = ReplicatedStorage:FindFirstChild("RemoteEvent") --  Remote event inside ReplicatedStorage

function Clicked() --  Function
	RemoteEvent:FireAllClients() --  Firing the remote event to all clients (everyone in game)
end

Button.MouseButton1Click:Connect(Clicked) --  Firing the function above (Clicked) when the TextButton is clicked.

Local Script inside StarterPlayerScripts:

local Players = game:GetService("Players") --  Players
local Player = Players.LocalPlayer --  Local Player
local ReplicatedStorage = game:GetService("ReplicatedStorage") --  ReplicatedStorage
local RemoteEvent = ReplicatedStorage:FindFirstChild("RemoteEvent") --  Remote event inside ReplicatedStorage

function ShowGUI() --  Function
	Player:WaitForChild("PlayerGui"):FindFirstChild("ScreenGui").Enabled = true --  Waiting for the PlayerGui, finding the GUI, then making it visible.
end

RemoteEvent.OnClientEvent:Connect(ShowGUI) --  Firing the function above (ShowGUI) when a signal is received from the remote event.

Obviously you would need to add the rest of the code, but that should work for showing everyone a GUI. Hope this helps!

This is make error, -

Infinite yield possible on 'ReplicatedStorage:WaitForChild("DisplayInterface")'

Being one of the first users to access ChatGPT and has seen countless replies, unfortunately your reply is generated using ChatGPT, and none of the text written here has been done by yourself. Please at least try the minimal to hide the fact you used ChatGPT for this.

@SerBogdan03, that script is literally wrong. Don’t listen to him. He did not even bother to check for errors in the first place.

@ChrisMRothschild, your script is also wrong.

You can’t put a ServerScript in SurfaceGui unless the ContextAction is Client, and you can’t do FireAllClients from the client, I’m pretty sure?

@SerBogdan03 Let’s get back to the issue, I will tell you how to do this.
First, this is the LocalScript:

-- Put this in StarterPlayerScripts!
local Players = game:GetService("Players") -- It's a better practice to use GetService instead of game.Players
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
-- For this, create a RemoteEvent in ReplicatedStorage and name it "RemoteEvent" (default)

local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")

local countdown = nil
-- Replace nil with where your countdown is located
-- In this case, "script.Parent.Parent.CountDown" does not tell me anything.
-- Use "PlayerGui:WaitForChild([INSERT_SCREENGUI_NAME]):WaitForChild([INSERT_FRAME_NAME]).CountDown instead
-- Just remember to replace [INSERT_SCREENGUI_NAME] and [INSERT_FRAME_NAME] with the actual names of the ScreenGui and Frame

local button = nil
-- Replace nil with where your button is located
-- Same case as countdown

local Notification = PlayerGui:WaitForChild("Notification"):WaitForChild("NotificationFrame")
-- Don't refer to StarterGui because it does not replicate to the client!
-- Use PlayerGui instead. StarterGui merely clones the Gui to the client.

local function beginCountDown()
    countdown.Visible = true
    Notification.Visible = true
    for i = 10, 1, -1 do
        countdown.Text = i
        task.wait(1)
        RemoteEvent:FireServer(i)
    end
    countdown.Text = ""
    countdown.Visible = false
    Notification.Visible = false
end

button.Activated:Connect(beginCountDown)
-- Use Activated instead of MouseButton1Click because it is more efficient
RemoteEvent.OnClientEvent:Connect(function(t)
    countdown.Text = tostring(t)
end)

Now the ServerScript:

-- Put this in ServerScriptService!
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

RemoteEvent.OnServerEvent:Connect(function(player, i)
    RemoteEvent:FireAllClients(i)
end)

If it does not work, or you need any explanation, you may reply.

  1. CountDown at SurfaceGUI. - this script part
local countdown = nil
-- Replace nil with where your countdown is located
-- In this case, "script.Parent.Parent.CountDown" does not tell me anything.
-- Use "PlayerGui:WaitForChild([INSERT_SCREENGUI_NAME]):WaitForChild([INSERT_FRAME_NAME]).CountDown instead
-- Just remember to replace [INSERT_SCREENGUI_NAME] and [INSERT_FRAME_NAME] with the actual names of the ScreenGui and Frame

  1. What was originally in the plans - there is a Surface GUI on which there is a Text Button, when pressed, a “Notification” window pops up In the interior of which “NotificationFrame” along with “textLabel” on which a certain text that is set for each button is defined.
  2. Idk why, text at “Notification button” where CountDown not at good status, Gui not showing.

You never specified it was a SurfaceGui, nor told me where the script was, come on, man.

Please re-read my 1 message where it is indicated that this is SurfaceGUI…

Whatever. At least post the hierarchy of your countdown Gui?

I make a video, and sent it at post where i say “Idk why, text at “Notification button” where CountDown not at good status, Gui not showing” And, yea “Gui Not showing” - its StarterGUI/PlayerGUI not make enable the Notification GUI

Seemed to work perfectly fine when I tested it :man_shrugging:

A few days have passed, as I understand, few people can help

It’s been just two days dude. People can’t help if you don’t explain your issue. Let’s try this, I’ll rewrite your code, just confirm me that this is correct: When anyone in the server taps a button, descendant of a SurfaceGui, a sibling countdown appears for everyone.

That is what you said. Then, a notification appears for everyone in the server. Is this correct?