✓ Accepted answer
Simple! But, there's two ways to do it! One way is easier to change for further changes, the other is just adjusting your above code.
Way 1) Adjusting Your Code
function ChangeText(txt)
for _,player in pairs(game.Players:GetPlayers()) do
pcall(function()
player.PlayerGui.ScreenGui.TextLabel.Text = txt
end)
end
end
while true do
ChangeText("Test")
wait(4)
ChangeTest("Test2")
wait(4)
end
Way 2) Efficiency!
You might've noticed that on many games, including faves like The Mad Murderer, the text usually at the top of the screen displays the status of the game, which changes text just like you're intending to do. You could do the first way a lot if you wanted, but the repetition would surely knacker you out!
Here's what people like loleris do: create a StringValue in ReplicatedStorage called "GameStatus" or something. Set its value to something generic, e.g. "Loading Game..." or just blank (this part isn't important). Then, in the textlabel, add a script:
local status = game.ReplicatedStorage:WaitForChild("STRINGVALUE_NAME")
function UpdateText()
script.Parent.Text = status.Value
end
status.Changed:connect(UpdateText)
UpdateText()
and in that ServerScriptService script:
local status = game.ReplicatedStorage:WaitForChild("STRINGVALUE_NAME")
while true do
status.Value = "Test"
wait(4)
status.Value = "Test2"
wait(4)
end
Now, any script in the place can change the text globally- not that one script! This makes it easier and more dynamic, as the changing of the text depends on the client rather than the server!
Hope this has helped!
Cheers :)
CD
3 comments
Wow you sound so pro, thanks!
Way 2) Thought me a lot. Thanks a lot :)
You're welcome! Happy to help ;)