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)
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.
nvm the thanks above, the script still didnt create a screengui
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.
literally i'm posting a comment of the post above with do you have to use localscript, i found you two that say that its localscript. thanks
This is a poor answer. First, you don't "call" LocalPlayer. Second, your sentence about ReplicatedFirst was irrelevant and made no sense. Finally, your explanation is not correct. The server doesn't try to find a player called LocalPlayer because the LocalPlayer property exists. The property is just nil for scripts running on the server, thus the error.
yeah i use random words, quiet
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
you cant get the LocalPlayer from a server script
@theking48989987 but i can with a localscript?
yes, because local scripts are clientside and LocalPlayer is clientsided
can localscripts fireserver:()?
I edited my answer? I dont know what else the problem occuring may be caused by