Hi! So I Have A Loading Menu For My Game But It Everywhere on my screen when its in startergui, how do you make a script moving a GUI from workspace to startergui? [PROBLEM SOLVED]
Try:
local newGui = workspace:WaitForChild(--Here is your gui name--):Clone()
newGui.Parent = plr.PlayerGui
To add things up, plr
is not a function from roblox, it’s a variable. To get the plr
just use
game.Players.PlayerAdded:Connect(function(plr)
-- his code here
end)
You should use script:WaitForChild(LoadingGui, 60)
in that statement since the ui is a child of the script.
Also since you’ve solved it, solution @N1njaNooby2’s answer because he contributed mostly on what the function must do.
Because the ScreenGui is instanced by the server (created by the server) you don’t need to use “WaitForChild()” to wait for its replication.
workspace.ScreenGui
would suffice.
Yes, WaitForChild() expects the argument passed to it to be a string value representing the name of the instance being waited for. In this case you don’t need to wait for the instance as it has been created by the server and as such does not need to replicate beforehand.
But for the sake of clarification, you’d need to do WaitForChild("LoadingGui")
instead.
local Players = game:GetService("Players")
local Gui = script.ScreenGui
Players.PlayerAdded:Connect(function(Player)
local GuiClone = Gui:Clone()
GuiClone.Parent = Player.PlayerGui
end)
This wouldn’t work because WaitForChild() does not expect instance values to (values which are objects) to be passed as arguments to it, instead you need to pass the name in the form a string type value of the instance being waited for.