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

How can i allow specific people to view a screen gui?

Asked by
ssieej 7
2 years ago

So basically, I want to make it so only me and my friend have access to a ScreenGui. any help?

3 answers

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

Put your screen Gui in ReplicatedStorage and put the script in ServerScriptService.

local players = {"sgtbermido1"} --Change the names to whoever you're giving the gui to
local gui = game.ReplicatedStorage.ScreenGui --Change ExampleGui to the Name of the Gui you're giving to the allowed players

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
        for i = 1, #players do
            if players[i] == plr.Name then
                gui:Clone().Parent = plr:WaitForChild("PlayerGui") 
            end
        end
    end)
end)

or

put this inside of your button

if game.Players.LocalPlayer.Name == "jackwater0" and "jackwater600" then ---- Change "YourNameHere" to your Roblox Username and "FriendsNameHere" to your friend's username
    script.Parent.Visible = true
else
    script.Parent.Visible = false
end

make sure you uncheck the Visible of the button in properties

0
I recommend to use a UserId instead of the player username. Since players can rename their username into something else, therefore when they join the game, it wouldn't recognize them. But UserId's cannot be changed. NotThatFamouss 605 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Here is a quick script that you can add and play around with:


local player = script.Parent.Parent.Parent local gui = script.Parent if player.Name == "YourNameHere" or player.Name == "YourFriendsNameHere" then script.Parent.Frame.Visible = true elseif player.Name ~= "YourNameHere" or player.Name == "YourFriendsNameHere" then script.Parent.Frame.Visible = false end
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You can maybe make a group (Or use a group that you own already) and make a rank for you and your friend and use this script to allow only the two.

local players = game:GetService("Players")
local player = players.LocalPlayer

local GuiFrame = script.Parent -- Change "GuiFrame" to the name of your ScreenGui.Frame

if player:GetRankInGroup(10490042) >= 254 then -- Change "GroupID" and insert your Group ID, and also change "254" to the number of your friend's rank (It should be the 2nd most powerful role in the group, you may decide to change it or not.)
    GuiFrame.Visible = true -- Change "GuiFrame" to the name of your ScreenGui.Frame
else
    GuiFrame.Visible = false-- Change "GuiFrame" to the name of your ScreenGui.Frame
end

This should work, as I've tested it. Let me know!

Answer this question