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

Procedural Generation Loading script not working?

for i = 1, 250 do
	local TPart = Instance.new("Part", workspace)
	TPart.Anchored = true
	TPart.Size = Vector3.new(math.random(30), math.random(30), math.random(30))
	TPart.CFrame = CFrame.new(math.random(-100, 100), TPart.Size.Y/2, math.random(-100, 100))
	for iterator, player in pairs(game.Players:GetChildren()) do
  		local character = player.Character or game.Workspace:WaitForChild(player.Name)
		if character then
			character.Torso.Anchored = true
		end
			if i < 250 then
				game.StarterGui.ScreenGui.TextLabel.Text = "Number of parts loaded: " .. i
			else
				game.StarterGui.ScreenGui.TextLabel.Text = "Welcome! Please enjoy your stay!"
			end
			if i == 250 then
				character.Torso.Anchored = false
			end
		end
		wait(.01)
		i = i + 1
	end

I was making a procedural generation script, and a loading screen with a ScreenGui but the text isn't changing. Anyone know why? Thanks! :D

1 answer

✓ Accepted answer

You're only editing the GUI in the StarterGui so no player will see the change as their version of the GUI is not being updated.

To fix this, go to lines 12 and 14 and change game.StarterGui to player.PlayerGui so that the script edits the player's GUI.

for i = 1, 250 do
    local TPart = Instance.new("Part", workspace)
    TPart.Anchored = true
    TPart.Size = Vector3.new(math.random(30), math.random(30), math.random(30))
    TPart.CFrame = CFrame.new(math.random(-100, 100), TPart.Size.Y/2, math.random(-100, 100))
    for iterator, player in pairs(game.Players:GetChildren()) do
        local character = player.Character or game.Workspace:WaitForChild(player.Name)
        if character then
            character.Torso.Anchored = true
        end
            if i < 250 then
                player.PlayerGui.ScreenGui.TextLabel.Text = "Number of parts loaded: " .. i
            else
                player.PlayerGui.ScreenGui.TextLabel.Text = "Welcome! Please enjoy your stay!"
            end
            if i == 250 then
                character.Torso.Anchored = false
            end
        end
        wait(.01)
        i = i + 1
    end

I hope my answer helped you. If it did, be sure to accept it.

1 comment

0

I'll give it a try. Thanks!

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