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

How do I make a TextLabel update when the text changes?

Asked by 9 years ago

I've seen TextLabels that update without respawning you.... but mine won't. The text changes, but the game won't update. Saying print(game.StarterGui.ScreenGui.Frame.TextLabel.Text) shows the outcome, which is the text I want it to be, but it won't update unless I respawn myself. Help?

0
Post the code please. Validark 1580 — 9y
0
LordDragonZord and I answered how we could, but it would be easier to answer if you explained more. Such as if you're editing in Edit Mode or if you're changing it in-game etc alphawolvess 1784 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

Use Changed event!


Changed

This fires whenever some property of something changes:

workspace.Changed:connect(function()
    print("Workspace changed!")
end)

workspace.Name = "Worksp@ce"

To do this, just do the samething as I did with workspace

--LocalScript
local plyr = game:GetService("Players").LocalPlayer

game:GetService("StarterGui").ScreenGui.Frame.TextLabel.Changed:connect()
    plyr.PlayerGui.ScreenGui.Frame.TextLabel.Text = game.StarterGui.ScreenGui.Frame.TextLabel.Text
end)

The problem is you're changing the screengui's text not the playergui. Instead of doing Changed you could do:

--Normal Script

function text(message)
    for _,plyr in pairs(game:GetService("Players"):GetPlayers()) do
        plyr.PlayerGui.ScreenGui.Frame.TextLabel.Text = message
    end
end

text("Testing") --Replace "Testing" with the message. This way you can keep changing it
wait(3)
text("Hi")

Hope it helps!

Ad
Log in to vote
0
Answered by 9 years ago

First of all, GUI's should be scripted with a LocalScript. All changes you see for your character are changes to that GUI on your Client and to view it, you would go Players>PlayerName>PlayerGui>GUIHierarchy...

So, your problem is that you're looking at the GUI that is in StarterGui which is receiving NO changes! I don't know if the printing is happening in edit mode or what you're actually trying to do but I will tell you some information bellow that may be of help.

First, you need to print the Text from the GUI on your Client. If you're doing this from a LocalScript then here's an example of what you'd do:

print(game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text)

Like I said, I don't know exactly what you're doing so I cannot give a very useful example with a Script, but here is two:

  • In Edit Mode for CommandBar or just a script in your game and you know their name:
print(game.Players.EraGamerXI.PlayerGui.ScreenGui.Frame.TextLabel.Text)
  • Using the PlayerAdded event to get that player already:
game.Players.PlayerAdded:connect(function(player)
    print(player.PlayerGui.ScreenGui.Frame.TextLabel.Text)
end)

Ask any questions in Comments if needed and accept if I helped!

Answer this question