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

Script not changing the text of a gui?

Asked by
Benbebop 1049 Moderation Voter
5 years ago

I made this script to get how many instances are in the game and displaying that.

local TotalInstances = game:GetChildren()
local Stats = game:GetService("Stats")

while true do
    script.Parent.Text = Stats.InstanceCount .. "/" .. #TotalInstances
end

the script does not change the gui's text. Whats wrong?

1 answer

Log in to vote
1
Answered by 5 years ago

Alrighty, I fixed your problem. First off, make a ScreenGui in StarterGui then add a TextLabel to it. And then add a LocalScript to the TextLabel. Then I added this script and everything worked!

local TotalInstances = game:GetChildren()
local Stats = game:GetService("Stats")

while true do
    wait()
    script.Parent.Text = Stats.InstanceCount .. "/" .. #TotalInstances
end

I hope this helped!

0
So was the problem not having a wait statement? Benbebop 1049 — 5y
0
Your problem was most likely having a normal script in the TextLabel which does not even run because it is in the Client. ScriptedEli 101 — 5y
0
You could also use while wait() do so there doesn't need to be that wait() statement. harstud 218 — 5y
Ad

Answer this question