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

TextLabel doesn't update?

Asked by 10 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

I have a textLabel that i want to change what it says when the amount of players is more than 2. Everything works fine buttt.... it doesn't change. I have to reset to see the difference. Is their something i'm overlooking or am i gonna have to use a different text GUI?

3 answers

Log in to vote
0
Answered by 10 years ago

I've run into this problem a lot of times with games I've made, the #1 solution I have found was to put a StringValue into Lighting and name it "Alert" and do the following

Script that changes the text:

    local alert = game.Lighting.Alert
    alert.Text = "Test String"
    wait(2)
    alert.Text = "Test #2"

Script Inside the TextLabel:

    local alert = game.Lighting.Alert
    update = function()
        script.Parent.Text = alert.Value
    end
    update()

    alert.Changed:connect(update)
0
THANK YOU! RobloxHelper49 55 — 10y
Ad
Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago
for i,v in pairs(game.Players:GetChildren()) do
v.PlayerGui.GUIAndLocationHere
end

This code will loop through all the players currently in the game and execute the action per player.

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

Rather than iterating through each player, I'd have a script inside each GUI that updates the TextLabel when the number of players changes. If I was you, this is what I'd have-

local Label = script.Parent
local Players = Game:GetService("Players")

function update()
    Label.Text = Players.NumPlayers .. " players"
end

Players.Changed:connect(function(property)
    if property == "NumPlayers" then
        update()
    end
end)

Answer this question