Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Can I Make The TextLabel Say the Same Thing For all Players?

script.Parent.ClickDetector.MouseClick:connect(function(player)
	for i,v in pairs(game.Players:GetPlayers()) do
		

local randomVars = {"This One As Well", "Oof", "This One Too", "This one",  }
local randomVar = randomVars[math.random(#randomVars)] -- picking a random variable from the table
	print(randomVar)
		v.PlayerGui.ScreenGui.Frame.TextLabel.Text = (randomVar)
		end
	
		end)

For the example above, I made up a random table. But what I want is for the text label to say the same thing for all the players in the server. With the above code, everyone's text changes, but its all different and random, which I know why, I just do not how to make it all the same.

1 comment

0

fire the local script into a server script using RemoteEvents or RemoteFunctions

2 answers

✓ Accepted answer
for i,v in pairs(game.Players:GetPlayers()) do
-- this would make it so it rerolls the variable for every player.
end


-- instead of that you could do

-- get the one text you want all of the players to see
local randomVars = {"This One As Well", "Oof", "This One Too", "This one",  }
local randomVar = randomVars[math.random(#randomVars)]

-- now loop through all the players and change their text
for i,v in pairs(game.Players:GetPlayers()) do
	v.PlayerGui.ScreenGui.Frame.TextLabel.Text = (randomVar)
end

another option could be event:FireAllClients(randomVar)

1 comment

0

Thank You!

fire the local script into a server script using RemoteEvents or RemoteFunctions

if you dont know what that is, this dude will teach you.

https://www.youtube.com/watch?v=GwhPXyYKkwU

and i know im supposed to be explaining but damn im tired man its late right now i should be sleeping

1 comment

0

Do make sure to elaborate the answer when you're well-rested!

This discussion is preserved as it was. New answers, comments, and votes are closed.