New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# Script not changing the text of a gui?

Benbebop 571
5 months 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

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 571 — 5mo
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 — 5mo
0
You could also use while wait() do so there doesn't need to be that wait() statement. Harruchs 198 — 5mo