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

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

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

✓ Accepted answer

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!

1 comment

0

Thank you so much!

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