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

Why won't my screen GUI Work?

Asked by 10 years ago

Hello! I am making a Gui so that when Someone joins my game, A gui pops up with an ImageLabel and a ImageButton. The button is supposed to remove the Gui.

This is what I have so far; Note that nothing happens in the StarterGui and nothing happens in the Output.

function onPlayerEntered(player)
    Sg = Instance.new("ScreenGui", game.StarterGui)
    Fr = Instance.new("Frame", Sg)
    Fr.Size = UDim2(0,100, 0,100)
    Fr.Position = UDim2(0,0, 0,0)
    Fr.BackroundTransparency = 1
    Il = Instance.new("ImageLabel", Fr)
    Il.size = UDim2(7,100, 4,100)
    Il.Position = UDim2(0.7,0, 0.4,0)
    Il.Image = "rbxassetid://184730943"
    Fr1 = Instance.new("Frame",Sg)
    Fr1.Size = UDim2(0,100, 0,100)
    Fr1.Position = UDim2(0,0, 0,0)
    Fr1.BackroundTransparency = 1
    Il1 = Instance.new("ImageButton",Fr1)
    Il1.size = UDim2(-0.5,100, -0.5,100)
    Il1.Position = UDim2(9.19,0, 0.4,0)
    Il1.Image = "rbxassetid://65415651"
    Il1.MouseButton1Click:connect(function()
    Game.StarterGui.ScreenGui.Remove
end)

onPlayerEntered:Connect(player)

Any solutions?

3 answers

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
10 years ago
function onPlayerEntered(player)
    Sg = Instance.new("ScreenGui", game.StarterGui)
    Fr = Instance.new("Frame", Sg)
    Fr.Size = UDim2.new(0,100, 0,100)
    Fr.Position = UDim2.new(0,0, 0,0)
    Fr.BackroundTransparency = 1
    Il = Instance.new("ImageLabel", Fr)
    Il.size = UDim2.new(7,100, 4,100)
    Il.Position = UDim2.new(0.7,0, 0.4,0)
    Il.Image = "rbxassetid://184730943"
    Fr1 = Instance.new("Frame",Sg)
    Fr1.Size = UDim2.new(0,100, 0,100)
    Fr1.Position = UDim2.new(0,0, 0,0)
    Fr1.BackroundTransparency = 1
    Il1 = Instance.new("ImageButton",Fr1)
    Il1.Size = UDim2.new(-0.5,100, -0.5,100)
    Il1.Position = UDim2.new(9.19,0, 0.4,0)
    Il1.Image = "rbxassetid://65415651"
    Il1.MouseButton1Click:connect(function()
        Game.StarterGui.ScreenGui:Destroy()
    end)
end)

game.Players.PlayerAdded:connect(onPlayerEntered(player))
0
Okay, this works, However when I click on the Button that is supposed to destroy it, nothing happens. IN the Output it says "Attempt To Call Nil Value" Any help? minikitkat 687 — 10y
0
I'll help with this one. MrSmenry forgot an important factor. On line 20, change 'game.StarterGui' to 'player.PlayerGui'. You should also do that on line 2 to make it more efficient. Shawnyg 4330 — 10y
0
This made the entire script not work. Sorry. minikitkat 687 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

solution one: just make the gui from the actual frame n stuff, it will be a lot easier.

Log in to vote
0
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(Plr)
Sg = Instance.new("ScreenGui", Plr:WaitForChild('PlayerGui'))
    Fr = Instance.new("Frame", Sg)
    Fr.Size = UDim2(0,100, 0,100)
    Fr.Position = UDim2(0,0, 0,0)
    Fr.BackroundTransparency = 1
    Il = Instance.new("ImageLabel", Fr)
    Il.size = UDim2(7,100, 4,100)
    Il.Position = UDim2(0.7,0, 0.4,0)
    Il.Image = "rbxassetid://184730943"
    Fr1 = Instance.new("Frame",Sg)
    Fr1.Size = UDim2(0,100, 0,100)
    Fr1.Position = UDim2(0,0, 0,0)
    Fr1.BackroundTransparency = 1
    Il1 = Instance.new("ImageButton",Fr1)
    Il1.size = UDim2(-0.5,100, -0.5,100)
    Il1.Position = UDim2(9.19,0, 0.4,0)
    Il1.Image = "rbxassetid://65415651"
    Il1.MouseButton1Click:connect(function()
    Sg:remove()
end)

Answer this question