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

Procedural Generation Loading script not working?

Asked by 8 years ago
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

Log in to vote
1
Answered by 8 years ago

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.

0
I'll give it a try. Thanks! RadiantSolarium 35 — 8y
Ad

Answer this question