Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui Not Working?

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)

1 answer

✓ Accepted answer

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!

8 comments

0

It's still not working

0

Wait, what do you mean by a sever script?

0

Server*

0

A server script is the script that does not have the head in the picture of it, when you insert it, insert one called "Script" not "LocalScript", and put it under ServerScriptService

0

A regular script. So, a script that's not a LocalScript or ModuleScript.

0

Wow, thanks, But i don't understand why you would put it in a regular script because everyone say's to put Gui's in a local script inside of StarterGui

0

Well you only need to do that if you're using Properties or Data restricted to LocalScripts. This includes things like 'game.Players.LocalPlayer'

0

Ok, Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.