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

GUI's not showing up when moved to it's parent?

Asked by
gr3uh 16
3 years ago

So I made a script that moves everything out of a folder to it's location. The problem is, is that when I play the game everything seems to go to it's location, but the GUI's from the folder go to StarterGui but don't show up... I really need help with this one XD!

Here is the code for locating the folders.

for _,i in pairs(game:GetService("Players"):GetPlayers()) do
    i.CharacterAppearanceId = 0
    i:LoadCharacter()
    wait()
    i.Character.Humanoid.Health = 0
    wait()
    i.Character:Remove()
    wait()
    i:LoadCharacter()
end

local rep = script.rep
wait(1)
for _, object in pairs(rep:GetChildren()) do -- this then gets rid of the folder
    newObject = object
    newObject.Parent = game.ReplicatedStorage
end

local work = script.work
wait(1)
for _, object in pairs(work:GetChildren()) do -- this then gets rid of the folder
    newObject = object
    newObject.Parent = game.Workspace
end

local gui = script.gui
wait(1)
for _, object in pairs(gui:GetChildren()) do
    newObject = object
    newObject.Parent = game.StarterGui
end

local sscript = script.sscript
wait(1)
for _, object in pairs(sscript:GetChildren()) do
    newObject = object
    newObject.Parent = game.ServerScriptService
end

local sstorage = script.sstorage
wait(1)
for _, object in pairs(sstorage:GetChildren()) do
    newObject = object
    newObject.Parent = game.ServerStorage
end





game.Players.PlayerAdded:Connect(function(Plr)
        Plr.CharacterAppearanceId = 0
    Plr:LoadCharacter()
    wait()
    Plr.Character.Humanoid.Health = 0
    wait()
    Plr.Character:Remove()
    wait()
    Plr:LoadCharacter()
    local sound = script.Play
    wait(5)
    sound:Play()
end)

1 answer

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
3 years ago

So I have a Déjà vu, since I just answered very similar question. My assumption is that you want contents of gui go to each PlayerGui and not to the StarterGui, right? Scripts moving stuff to StarterGui do not really make sense if they are to be run during the game.

It may make sense though, if this is a studio plugin script though. However since you are getting players at the beginning, I do not think this is the case.

Here is the proper way to copy gui contents to each player screen:

local gui = script.gui
wait(1)
for _, player in pairs(game.Players:GetChildren()) do

    for _, object in pairs(gui:GetChildren()) do

        newObject = object:Clone() -- without cloning we could only do this once (for one player)
        newObject.Parent = player.PlayerGui

    end

end
gui:ClearAllChildren() -- if you want to empty the contents after

I hope this helps!

0
Thank you so much! gr3uh 16 — 3y
Ad

Answer this question