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
local ScreenGui = Instance.new("ScreenGui") ScreenGui.Parent = player.PlayerGui local frame = Instance.new('ImageLabel') frame.Parent = player.PlayerGui:WaitForChild("ScreenGui") frame.Image = 'rbxassetid://3570695787' frame.Size = UDim2.new(0, 228,0, 60) frame.ImageColor3 = Color3.fromHSV(85, 170, 255) frame.Position = UDim2.new(-1, 0,0.914, 0) frame.BackgroundTransparency = 0.7 local text = Instance.new("TextLabel") text.Parent = player.PlayerGui.ScreenGui:WaitForChild("Frame") text.Size = UDim2.new(0, 228,0, 60) text.Position = UDim2.new(-1, 0,0.914, 0) text.BackgroundTransparency = 1 wait(1) player.Name = text.Text frame:TweenPosition(UDim2.new(0.006, 0,0.914, 0), 'Out', 'Sine' )
game.Players.PlayerAdded:Connect(function(player) -- Creating the ScreenGui. -- First you must define it (local statement) local Example1 = Instance.new("ScreenGui") -- When you create a new instance, you can actually parent it whilst doing so, so instead, let's delete this screen gui. Example1:Destroy() -- Now, let's create one and set the parent along with it. local ScreenGui = Instance.new("ScreenGui",player:WaitForChild("PlayerGui")) local Frame = Instance.new("ImageLabel",ScreenGui) -- You have just set it's parent to the recent GUI you made. Frame.Image = 'rbxassetid://3570695787' Frame.Size = UDim2.new(0, 228,0, 60) Frame.ImageColor3 = Color3.fromHSV(85, 170, 255) Frame.Position = UDim2.new(-1, 0,0.914, 0) Frame.BackgroundTransparency = 0.7 local Text = Instance.new("TextLabel",Frame) -- Ignore that comment about line 16, its replaced with this comment. Text.Size = UDim2.new(0, 228,0, 60) Text.Position = UDim2.new(-1, 0,0.914, 0) Text.BackgroundTransparency = 1 wait(1) -- Why wait? -- One mistake, you have attempted to change the player's name to the given text on the TextLabel, consider turning this around. Text.Text = player.Name -- Connecting the PlayerAdded function and "end)"ing it isn't necessary if you have done something like that already. end) -- This script should function properly, your welcome :)
Try this:
local ScreenGui = Instance.new("ScreenGui") ScreenGui.Parent = player.PlayerGui local frame = Instance.new('ImageLabel') frame.Parent = player.PlayerGui:WaitForChild("ScreenGui") frame.Image = 'rbxassetid://3570695787' frame.Size = UDim2.new(0, 228,0, 60) frame.ImageColor3 = Color3.fromHSV(85, 170, 255) frame.Position = UDim2.new(-1, 0,0.914, 0) frame.BackgroundTransparency = 0.7 local text = Instance.new("TextLabel") text.Parent = player.PlayerGui.ScreenGui:WaitForChild("ImageLabel") text.Size = UDim2.new(0, 228,0, 60) text.Position = UDim2.new(-1, 0,0.914, 0) text.BackgroundTransparency = 1 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