Answered by
4 years ago Edited 4 years ago
Hello. Here is a more explained version of Raccoonyz's answer.
When a player is added, an object/instance gets created inside the player called PlayerGui
. It is the container for the guis the player has on-screen. The guis that get cloned are inside StarterGui
, another container.
So, you must parent the cloned gui to the PlayerGui
.
Also, you must first create a ScreenGui
and then put the object in it as TextLabels that aren't parented to a ScreenGui will not show up on-screen.
Add this code to the script (make sure it's a LocalScript):
01 | game.Players.LocalPlayer:WaitForChild( "PlayerGui" ) |
05 | local screenGui = Instance.new( "ScreenGui" ) |
08 | local guiObject = script.Parent:Clone() |
10 | guiObject.Position = UDim 2. new( 0 , 0 , 0.2 , 0.1 ) |
12 | guiObject.Parent = screenGui |
14 | screenGui.Parent = game.Players.LocalPlayer.PlayerGui |
Also, when you use Clone()
, the object is made but not parented. To parent it, you must use the "Parent" property.