How to make a gui that only the creator can see

I forgot how to make a gui that only the creator can see.
Can anybody help me?

Well I suggest doing some research on the API, but you just check when a player is added for their playerid. If it is not the same as what is required to see the gui the just end.

1 Like

Make a script in ServerScriptService, and paste the following code into it.

local GUIName = "ScreenGui"
function PlayerAdded(plr)
    if plr.UserId == game.CreatorId then
        script:FindFirstChild(GUIName):Clone().Parent = plr:WaitForChild("PlayerGui")
for i,v in pairs(game:GetService("Players"):GetPlayers()) do

Change GUIName to the name of you GUI, and parent the GUI to the script you added.

1 Like

LocalScript or Script?

Script in serverscriptservice

1 Like

I will try. So, I guess my problem is solved

Mark it as the solution please.

Ok. I forgot to to do that.

You can actually shorten that code by a lot.
Put this inside a LocalScript inside the ScreenGui.

      if game.Players.LocalPlayer.UserId ~= game.CreatorId then
            script.Parent:Destroy() -- destroy it for extra security
1 Like

The gui will still replicate to the client, some bad actor might be able to fake the gui and scam some users saying they are the owner.
It’s honestly just better to do this and on the server.

1 Like
local Players = game:GetService("Players")
local Gui = script.Parent #-- Gui under game.ServerScriptService, server-script under the Gui since LocalScript objects only run under certain containers
local function onPlayerAdded(player)
    if player.UserId == "[Creator's User Id]" then #-- if the player's user id equals a predefined id
        local PGui = player:WaitForChild("PlayerGui", 10) # wait fo the PlayerGui container to exist
        Gui:Clone().Parent = PGui #-- clone the Gui, and set the Parent property

Players.PlayerAdded:Connect(onPlayerAdded) #-- pass the callback to the listener

Lua code syntax highlighting also needs to work better, comments not being formatted normally.

1 Like

I believe you could do something like this in a localscript as well!

Let’s not forget clients have full control of their system, so it’d be less secure doing it all client-side.

True, but if the GUI’s functionalities are only going to affect the client it may not matter as much.

True, but only if that is the case

and it isn’t providing any sort of benefit to an extent where hiding it would be necessary (at that point it’d be better to not hide it at all) .

1 Like

Use local script or maybe just if player id and = and put id in

Use the get function and lock it to to id or the creator