I am trying to make a script that will open a menu when it is clicked however when I press the button this error pops up
It says I am attempting to index PlayerGui as nil.
Here’s the script.
Line 6 is where the error appears
local Shop = game.ReplicatedStorage.ScreenGui
local ShopButton = script.Parent
ShopButton.MouseButton1Click:Connect(function(Clicked)
local ShopClone = game.ReplicatedStorage.ScreenGui
ShopClone.Parent = game.Players.LocalPlayer.PlayerGui
if false then
return
end
end)
Yeah, try it in a LocalScript. The issue is, game.Players.LocalPlayer does not work in a server script, as it is referring to the local player, which is only on the client’s side.