Whenever I attempt to start the game with the GUI, it stays invisible and I get this error in the output:
15:34:21.197 - ServerScriptService.Script:14: attempt to index nil with 'PlayerGui'
math.randomseed(tick())
local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local clonedgui = billboardgui:Clone()
clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
clonedgui.TextLabel.BackgroundTransparency = 1
clonedgui.TextLabel.TextTransparency = 1
game.Players.PlayerAdded:Connect(function(player)
end)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
clonedgui.TextLabel.BackgroundTransparency = 0.45
clonedgui.TextLabel.TextTransparency = 0
clonedgui.TextLabel.Text = math.random(1, 20)
wait(0.3)
clonedgui.TextLabel.Text = math.random(1, 20)
wait(0.3)
clonedgui.TextLabel.Text = math.random(1, 20)
wait(0.3)
clonedgui.TextLabel.Text = math.random(1, 20)
wait(0.3)
clonedgui.TextLabel.Text = math.random(1, 20)
wait(0.3)
wait(1)
clonedgui.TextLabel.BackgroundTransparency = 1
clonedgui.TextLabel.TextTransparency = 100
end)
end)
end)

3 comments
After modifying it slightly, how would I use the player variable? Would it just be "game.Players.PlayerAdded:Connect(function(player)" or what?
Nevermind, figured it out! I had to use: game.Players:WaitForChild(player.Name).PlayerGui.ScreenGui.TextButton.MouseButton1Click:Connect(function()
good job!