Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script not changing the text of a gui?

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

✓ Accepted answer

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!

3 comments

0

So was the problem not having a wait statement?

0

Your problem was most likely having a normal script in the TextLabel which does not even run because it is in the Client.

0

You could also use while wait() do so there doesn't need to be that wait() statement.

This discussion is preserved as it was. New answers, comments, and votes are closed.