Hello! I am trying to clone a folder inside playerGui from a local script, but its not being cloned
The code is this
local player = game:GetService("Players").LocalPlayer
local replicated = game:GetService("ReplicatedFirst")
local SpawnUis = replicated.SpawnUis:Clone()
SpawnUis.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
But when i add wait() it magically works, like
local player = game:GetService("Players").LocalPlayer
local replicated = game:GetService("ReplicatedFirst")
local SpawnUis = replicated.SpawnUis:Clone()
wait(1)
SpawnUis.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
but i dont want to use wait() because of a potential laggy player. Also i dont understand why i can’t assign it’s parent instantly and instead i have to wait a second.
First i thought maybe i have to wait for playergui to load but even then it doesn’t work
you can’t create new guis on the client and have them visible
you should use a server script
the way how playergui works is: server has the gui, sends a copy to each client that joins the game
you can only add new UI via server, but you can customize the already existing UI via client
Yes that makes sense but i am not creating a new gui i am copying one and it somehow works when i add wait function for a second. If i parent everything to the playergui then there is another bug where i cant access the spawnui inside playergui even with waitforchild() and i again need to add wait. I wanted to have a workaround by parenting it to replicatedfirst so it loads first and then parent it to player but as you can see with the post, i get a similar problem. I can of course just add wait and skip the hassle but i dont think it’s reliable
local RF = game:GetService("ReplicatedFirst")
local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui") -- or plr:FindFirstChild("PlayerGui")
local SpawnUis = RF:WaitForChild("SpawnUis"):Clone() -- this could yield infinitely so i apologize
SpawnUis.Parent = plrGui
if this doesn’t work then i suggest doing it via server, or just doing it in startergui
Oh sorry i forgot about adding the console but no there is no infinite yield i also added a print after assigning the parent and it works so i suppose there is no yield?