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

Whats wrong with this?

Asked by
iLegitus 130
9 years ago

Ive tried doing the following but it didnt work?

while wait() do
    TF = game.ReplicatedStorage["GUI_Drive"].TopFrame:clone()
    TF.Parent = game.StarterGui
    for i = 1, #Players do 
        TF.Parent = Players[i].PlayerGui
    end
end

How do i make the part where it gives the Players the GUI,Only run once in the script? The while wait() do loop is soppost to run as an entire round. Much appricated if you helped?

1 answer

Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

I don't really understand what you mean in the last paragraph, but make sure you include the output. Players is a nil value because you don't define it anywhere, so there will be something in the output. Try this:

while wait() do
    local TF = game.ReplicatedStorage["GUI_Drive"].TopFrame:Clone() --Local variables are more efficient.
    TF.Parent = game.StarterGui
    local Players = game.Players:GetPlayers()
    for i = 1, #Players do 
        TF.Parent = Players[i].PlayerGui
    end
end

But this still will only give one player the GUI, since you only clone it once. You have to clone it for each and every player.

while wait() do
    local TF = game.ReplicatedStorage["GUI_Drive"].TopFrame:Clone()
    TF.Parent = game.StarterGui
    local Players = game.Players:GetPlayers()
    for i = 1, #Players do
        local gui = game.ReplicatedStorage["GUI_Drive"].TopFrame:Clone()
        gui.Parent = Players[i]:WaitForChild("PlayerGui") --Just in case it hasn't loaded yet.
    end
end
0
Thanks,And what i meant is that it only runs ONCE in the loop,Per loop. iLegitus 130 — 9y
0
Read it now Perci1 4988 — 9y
Ad

Answer this question