Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
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.

0
fire the local script into a server script using RemoteEvents or RemoteFunctions likejagar 17 — 2y

2 answers

Log in to vote
2
Answered by 2 years ago
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)

0
Thank You! ChefDevRBLX 90 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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

0
Do make sure to elaborate the answer when you're well-rested! radiant_Light203 1166 — 2y

Answer this question