Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

GUI only certain people can see?

Asked by 8 years ago

How would I make a script that only allows certain people to able to see a GUI?

0
idk what kind of GUI you want, but if you want a SurfaceGui, then make the SurfaceGui and put it inside of StarterGui. Then make a script to set the SurfaceGui's Adornee to the part you want it on Scootakip 299 — 8y

2 answers

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago

The way GUIs work is that each player has their own PlayerGui inside their Player object, and they can only see GUIs inside that PlayerGui. When they join the game, anything inside the StarterGui is copied automatically into the player's PlayerGui.

To answer your question, the easiest way to do this is to make a GUI in the StarterGui with Visible set to false, then make a script that sets it to true if the person should be able to see the GUI.

For example, if I only wanted myself to be able to see the GUI and the GUI was called MyFrame, I would do this:

-- This is only a small example. The script won't work with FilteringEnabled.
game.Players.PlayerAdded:connect(function(player)
    -- In practice, UserId is preferred, but for this example I use Name.
    if player.Name == "IDidMakeThat" then
        player.PlayerGui.ScreenGui.MyFrame.Visible = true
    end
end)

Hopefully this will allow you to figure out how to achieve this in your specific case.

Ad
Log in to vote
0
Answered by 8 years ago

Maybye you should use Instance.new() to make a gui in game.Players.USERNAMEHERE?.PlayerGui

Answer this question