local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
How do you mention ScreenGui.Parent etc?
Error: Workspace.Gui to Lua 5:19: attempt to index field 'LocalPlayer' (a nil value)
You must have the script as a LocalScript
, Which can throw the errors that you represented in your question.
In addition to this, a recommendation from me, set the LocalPlayer before the script so if you want to refer to it multiple times in the script its overall easier to do such.
-->> Insert a localscript into Server script service
local player = game.Players.LocalPlayer local ScreenGui = Instance.new("ScreenGui", player.PlayerGui) -- Set the parent as the second paramater of the instance instantly parent it.
You need to call it from a localscript, which is in something like ReplicatedFirst. LocalPlayer is not replicated between server/client, so the server tries to find a player called LocalPlayer
with the script line you put, whilst a localscript would target the client.