Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gui Not Working?

Asked by 9 years ago

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

Log in to vote
2
Answered by
Scriptree 125
9 years ago

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!

0
It's still not working QuantumScripter 48 — 9y
0
Wait, what do you mean by a sever script? QuantumScripter 48 — 9y
0
Server* QuantumScripter 48 — 9y
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 Scriptree 125 — 9y
View all comments (4 more)
0
A regular script. So, a script that's not a LocalScript or ModuleScript. dyler3 1510 — 9y
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 QuantumScripter 48 — 9y
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' dyler3 1510 — 9y
0
Ok, Thanks QuantumScripter 48 — 9y
Ad

Answer this question