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.
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)
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