I have a Gui that is as big as the full screen and i have a frame2 that is a little smaller and i have a text label that is suppose to read the players name when they enter and say Hello 'playername' but when i add the plr function it breaks the whole gui and it's not there anymore. Please help.
--Here is my original Gui script
local screenGui=Instance.new("ScreenGui") screenGui.Parent=script.Parent local frame=Instance.new("Frame") frame.Parent=screenGui frame.Size=UDim2.new(1,0,1,0) frame.Position=UDim2.new(0,0,0,0) frame.BackgroundColor3 = Color3.new(0,0,0) local frame2=Instance.new("Frame") frame2.Parent=screenGui frame2.Size=UDim2.new(0.9,0,0.9,0) frame2.Position=UDim2.new(0.05,0,0.05,0) frame2.BackgroundColor3=BrickColor.White().Color local textLabel=Instance.new("TextLabel") textLabel.Parent=frame2 textLabel.Position=UDim2.new(0.05,0,0.05,0) textLabel.Size=UDim2.new(0.9,0,0.9,0) textLabel.BackgroundColor3=BrickColor.White().Color textLabel.Text='Hello'
This is when i add the plr function it breaks...
game.Players.PlayerAdded:connect(function(plr) local screenGui=Instance.new("ScreenGui") screenGui.Parent=script.Parent local frame=Instance.new("Frame") frame.Parent=screenGui frame.Size=UDim2.new(1,0,1,0) frame.Position=UDim2.new(0,0,0,0) frame.BackgroundColor3 = Color3.new(0,0,0) local frame2=Instance.new("Frame") frame2.Parent=screenGui frame2.Size=UDim2.new(0.9,0,0.9,0) frame2.Position=UDim2.new(0.05,0,0.05,0) frame2.BackgroundColor3=BrickColor.White().Color local textLabel=Instance.new("TextLabel") textLabel.Parent=frame2 textLabel.Position=UDim2.new(0.05,0,0.05,0) textLabel.Size=UDim2.new(0.9,0,0.9,0) textLabel.BackgroundColor3=BrickColor.White().Color textLabel.Text=('Hello '..plr.Name) end)
You did not parent it right, but everything else is fine! Also make sure that it is a server script, not a local script.
game.Players.PlayerAdded:connect(function(plr) local screenGui = Instance.new("ScreenGui") screenGui.Parent = plr:WaitForChild("PlayerGui") -- so that's the right way of parenting it local frame = Instance.new("Frame") frame.Parent = screenGui frame.Size = UDim2.new(1,0,1,0) frame.Position = UDim2.new(0,0,0,0) frame.BackgroundColor3 = Color3.new(0,0,0) local frame2 = Instance.new("Frame") frame2.Parent = screenGui frame2.Size = UDim2.new(0.9,0,0.9,0) frame2.Position = UDim2.new(0.05,0,0.05,0) frame2.BackgroundColor3 = BrickColor.White().Color local textLabel = Instance.new("TextLabel") textLabel.Parent = frame2 textLabel.Position = UDim2.new(0.05,0,0.05,0) textLabel.Size = UDim2.new(0.9,0,0.9,0) textLabel.BackgroundColor3 = BrickColor.White().Color textLabel.Text = 'Hello' end)
Hope that helped!