Hello,
i make a command that opens a GUI. If you run the Command it copy the GUI into the PlayerGui Folder. It works in Studio, but not online! I use a normal Script and NOT a LocalScript. Here is my Code:
function onChatted(message, player) if message == "/registerplayer" and tableContains(admins, player.Name) then print("GUI opening") game.ServerStorage.registerPlayer:Clone().Parent = game.Players.LocalPlayer.PlayerGui end end
Can it be that LocalPlayer only works with a LocalScript? And if LocalPlayer only works in a LocalScript, what Code do i need to use in a normal Script?
game.Players.LocalPlayer
only works in a LocalScript as it is aClient Side
script basically there are two sides of a server. The Server and the Client, LocalScripts are usually put into Player's Backpacks, StarterGui's etc.
In short game.Players.LocalPlayer
can only be used in a LocalScript.
Also you defined player on Line1 so just do:
local ServerStorage = game:GetService("ServerStorage") -- Function print("GUI opening") ServerStorage.registerPlayer:Clone().Parent = player.PlayerGui