My code isn't working for creating a gui when a player joins the server. This script is in StarterGui and is a LocalScript
Code:
local player = game.Players.LocalPlayer
01 | local ScreenGui = Instance.new( "ScreenGui" ) |
02 | ScreenGui.Parent = player.PlayerGui |
03 | local frame = Instance.new( 'ImageLabel' ) |
04 | frame.Parent = player.PlayerGui:WaitForChild( "ScreenGui" ) |
05 | frame.Image = 'rbxassetid://3570695787' |
06 | frame.Size = UDim 2. new( 0 , 228 , 0 , 60 ) |
07 | frame.ImageColor 3 = Color 3. fromHSV( 85 , 170 , 255 ) |
08 | frame.Position = UDim 2. new(- 1 , 0 , 0.914 , 0 ) |
09 | frame.BackgroundTransparency = 0.7 |
10 |
11 | local text = Instance.new( "TextLabel" ) |
12 | text.Parent = player.PlayerGui.ScreenGui:WaitForChild( "Frame" ) |
13 | text.Size = UDim 2. new( 0 , 228 , 0 , 60 ) |
14 | text.Position = UDim 2. new(- 1 , 0 , 0.914 , 0 ) |
15 | text.BackgroundTransparency = 1 |
16 | wait( 1 ) |
17 | player.Name = text.Text |
18 | frame:TweenPosition(UDim 2. new( 0.006 , 0 , 0.914 , 0 ), 'Out' , 'Sine' ) |
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | -- Creating the ScreenGui. |
03 | -- First you must define it (local statement) |
04 | local Example 1 = Instance.new( "ScreenGui" ) |
05 | -- When you create a new instance, you can actually parent it whilst doing so, so instead, let's delete this screen gui. |
06 | Example 1 :Destroy() |
07 | -- Now, let's create one and set the parent along with it. |
08 | local ScreenGui = Instance.new( "ScreenGui" ,player:WaitForChild( "PlayerGui" )) |
09 | local Frame = Instance.new( "ImageLabel" ,ScreenGui) -- You have just set it's parent to the recent GUI you made. |
10 | Frame.Image = 'rbxassetid://3570695787' |
11 | Frame.Size = UDim 2. new( 0 , 228 , 0 , 60 ) |
12 | Frame.ImageColor 3 = Color 3. fromHSV( 85 , 170 , 255 ) |
13 | Frame.Position = UDim 2. new(- 1 , 0 , 0.914 , 0 ) |
14 | Frame.BackgroundTransparency = 0.7 |
15 | local Text = Instance.new( "TextLabel" ,Frame) |
Try this:
01 | local ScreenGui = Instance.new( "ScreenGui" ) |
02 | ScreenGui.Parent = player.PlayerGui |
03 | local frame = Instance.new( 'ImageLabel' ) |
04 | frame.Parent = player.PlayerGui:WaitForChild( "ScreenGui" ) |
05 | frame.Image = 'rbxassetid://3570695787' |
06 | frame.Size = UDim 2. new( 0 , 228 , 0 , 60 ) |
07 | frame.ImageColor 3 = Color 3. fromHSV( 85 , 170 , 255 ) |
08 | frame.Position = UDim 2. new(- 1 , 0 , 0.914 , 0 ) |
09 | frame.BackgroundTransparency = 0.7 |
10 |
11 | local text = Instance.new( "TextLabel" ) |
12 | text.Parent = player.PlayerGui.ScreenGui:WaitForChild( "ImageLabel" ) |
13 | text.Size = UDim 2. new( 0 , 228 , 0 , 60 ) |
14 | text.Position = UDim 2. new(- 1 , 0 , 0.914 , 0 ) |
15 | text.BackgroundTransparency = 1 |
16 |
17 |
18 | wait( 1 ) |
Basically your referencing frame to the variable, and not the instance. Alternatively you could also use
text.Parent = player.PlayerGui.ScreenGui:WaitForChild(frame)
A string and a object are different