Making a script that makes everyone see the same GUI

Hello I am trying to make a script that makes a GUI appear for everyone, but I don’t really remember could I use this for it to work, or how’d I do that again, if this does not work, please explain how, and I’ll try to bring that with me for the next little project, using the same method.

game.Players.LocalPlayer.PlayerGui.Text.TextBox.Visible = true
game.Players.LocalPlayer.PlayerGui.Text.TextBox.FunctionScript.Disabled = false

And how would I make it so it says their username if I were to make it say their name in a text

1 Like

You would want to loop through every player in GetPlayers() table and make it visible.

1 Like

But how’d I do that, that’s the question?

Using for i,v in pairs(game.Players:GetPlayers()) do v is the variable for the player, meaning you can do v.PlayerGui.Text.Visible = true

2 Likes

So basically just replacing those two, with something simple like that?

1 Like

You can change the i and v variables to whatever. I is the index and V is the variable for the object your looping through.

1 Like

Sorry that I don’t really understand, still trying to get into scripting and all, but how would it work?? like for the script.

Cause I don’t really know if I need to make it like or something else like with that.

v.PlayerGui.Text.Visible = true
2 Likes

V is each of the players in the game. You are looping through each of them and setting the Text visibility to false. I would check out this website for more info. https://www.alvinblox.com/in-pairs-loops-i-v-in-pairs/

1 Like

Alright, I’ll be checking it out.

1 Like

No you wouldn’t. You would want to use game.Players:FindFirstChild(player.Name)

1 Like

They wanted everyone to see the gui, not just one person…

1 Like

I think I’ve solved your problem! In a server script, type:

local Players = game:GetService("Players")

local function showGui()
	for _,player in pairs(Players:GetPlayers()) do
		local gui = player.PlayerGui.Temporary
		gui.Enabled = true
	end
end

Then, call your showGui() function whenever you want to show it.
Change the GUI variable to whatever GUI you want to show to your players. I created one named Temporary for testing, but obviously, you can name it whatever you want.

Hope this helps!

Edit: I have tested this in Roblox Studio and it does work.

2 Likes

I’ll try that right now, hopefully it works!

1 Like

Did you try using a server script instead of a local script?

1 Like

It’s a server script, cause it isn’t gonna be a local script.

1 Like

I’m sure this worked, but not really working for me, but I’ll try again later.

1 Like

Hmm, that’s very strange. Would you mind sending a picture of your code? Maybe I can find the issue.

1 Like

Sure, I can.

It’s a joke event for my showcase game though (Taco’s basically, since people don’t like the song xD)

image

2 Likes

Okay, thanks for sending the screenshot! This should work:

local Players = game:GetService("Players")

function OnClicked()
	-- Add the following to the end of this function:
	for _,player in pairs(Players:GetPlayers()) do
		local gui = player.PlayerGui.Temporary
		gui.Enabled = true
	end
end

script.Parent.MouseButton1Down:Connect(OnClicked)

One thing to note for future reference is that with :Connect, Connect needs to be capitalized as shown above.

1 Like

I’ll check in a bit, I hope this works!