Cloning Issues with folders

I’m trying to clone a folder to my PlayerGui.
I tried cloning it in other places, that seemed to work. Yet not in my PlayerGui.

local players = {"EugeneFaung", "ROBLOX"}

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		for i = 1, #players do
			if players[i] == plr.Name then
				game.ServerScriptService["Close Air Support"].M1Client:Clone().Parent = plr:WaitForChild("Backpack")
				local clone =game.ServerScriptService["Close Air Support"]["Air Support UI"]:Clone()
				clone.Parent = plr.PlayerGui
				print("added")
			end
		end
	end)
end)
1 Like

Always do :WaitForChild() for PlayerGui.
plr:WaitForChild(“PlayerGui”)

1 Like
local players = {"EugeneFaung", "ROBLOX"}

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		for i = 1, #players do
			if players[i] == plr.Name then
				game.ServerScriptService["Close Air Support"].M1Client:Clone().Parent = plr:WaitForChild("Backpack")
				local clone =game.ServerScriptService["Close Air Support"]["Air Support UI"]:Clone()
				clone.Parent = plr:WaitForChild("PlayerGui")
				print("added")
			end
		end
	end)
end)

[/quote]

still doesn’t seem to work.

1 Like

Are there any errors in the output/developer console?

None except for another script that waits for Close Air Support UI to exist in PlayerGui.

Though the script does work the first time my Player and character spawns in

Here’s how everything is structured.
image

Is it printing “added”? If so, does it still print after the first time the character is added? (After the character respawns)

It prints “added” every time my character respawns.

Alright, here is a solution that should work: You don’t need to re-add the GUI everytime the character is added, just disable the ResetOnSpawn (or something similar) property under the GUI objects.

The thing is, The reason I’m cloning both of them is so that only select players get access to them. Is there a way I can put them into a select StarterGui?

Turning off that property doesn’t make it so anyone can have that GUI. All it does is that it stops the GUI from getting destroyed everytime the character is reset. (Of course only if the player even had it in the first place.)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.