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.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Script not changing the text of a gui?

Asked by
Benbebop 118
12 days 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
Eli_90 46
12 days 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 118 — 12d
0
Your problem was most likely having a normal script in the TextLabel which does not even run because it is in the Client. Eli_90 46 — 12d
0
You could also use while wait() do so there doesn't need to be that wait() statement. Ha_rriz 125 — 12d
Ad

Answer this question