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

Why won't my screen GUI Work?

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

✓ Accepted answer
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))

3 comments

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?

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.

0

This made the entire script not work. Sorry.

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

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)

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