Workspace.Gui To Lua 1:10: attempt to index field 'LocalPlayer' (a nil value) i got this error while making a gui i dont know how i just learned lua yesterday https://www.youtube.com/watch?v=yc_d8Zh95l0 that is where i learned from here is the script:
-- Farewell Infortality. -- Version: 2.82 -- Instances: local GuiMain = Instance.new("ScreenGui") local ClickGui = Instance.new("Frame") local Partinsert = Instance.new("TextButton") local p = game.Workspace --Properties: GuiMain.Name = "GuiMain" GuiMain.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
ClickGui.Name = "Click Gui" ClickGui.Parent = GuiMain ClickGui.BackgroundColor3 = Color3.new(0.545098, 1, 0.560784) ClickGui.BorderSizePixel = 6 ClickGui.Position = UDim2.new(0.618749976, 0, 0.626262665, 0) ClickGui.Size = UDim2.new(0, 263, 0, 143)
Partinsert.Name = "Part insert" Partinsert.Parent = ClickGui Partinsert.BackgroundColor3 = Color3.new(0.160784, 0.478431, 0.239216) Partinsert.BorderSizePixel = 7 Partinsert.Position = UDim2.new(0.117032252, 0, 0.32415545, 0) Partinsert.Size = UDim2.new(0, 200, 0, 50) Partinsert.Font = Enum.Font.SourceSans Partinsert.Text = "Insert Part" Partinsert.TextColor3 = Color3.new(0, 0, 0) Partinsert.TextSize = 14
Partinsert.MouseButton1Click:Connect(function() Part = Instance.new("Part") Part.Anchored = true Part.BrickColor = BrickColor.new("Neon orange") Part.Position = Vector3.new(0,0,0)
Part.Parent = game.Workspace end)

4 comments
Please use code blocks.
Alvinbloxx is the worst person to learn off of.
game.LocalPlayer can only be used via LocalScript or else it is always nil
by the way, please for god sake please use code blocks (select the code and press the lua icon when editing the question)