Can someone explain to me how I can make a GUI where only certain people can see it?
(I’m not asking for a whole system/script, I’m just asking for someone to explain it.)
Put the GUI in serverstorage and replicate it into PlayerGui for those who you want to access it.
Just put the ScreenGui inside of ServerStorage(to prevent exploiters for accessing it) and clone it to the playerGUI when a player joins. When a player joins, make sure to check if their name is inside of a table of people who can access the GUI. You can check this by using table.find(table, value, index).
Make the gui first, then put it into the ServerStorage
Have a server script and this will be the general layout of the script:
local SS = game:GetService("ServerStorage")
local GUI = SS:WaitForChild("GUItoBeCloned")
local WhitelistedPlayers = {} -- put the peoples usernames or userIds in here that you want to have the UI, put UserId would be better
game.Players.PlayerAdded:Connect(function(player)
if table.find(WhitelistedPlayers, player.UserId) then
local ClonedUI = GUI:Clone()
ClonedUI.Parent = player:WaitForChild("PlayerGui")
end
end)
So a global script is a normal script? (Sorry I’m kinda new to this stuff.)
Yes, a server script is a normal script, the reason I specified was that was because sometimes if I were to just say “Script” and not specify which, some people would use a local script.
Thank you! It helped me a lot.
You made an error, you said GUI.Parent = player:WaitForChild(“PlayerGui”) instead of ClonedUI.Parent = player:WaitForChild(“PlayerGui”)
I’d just like to clarify something. Although you’re giving the GUI to whitelisted players, don’t forget to add more server sided checks for remote events/functions because exploiters can access these at any time.
In addition, I’d personally go for a setup like this:
All players will have this moderation gui available in their player gui c/o starter gui to avoid making the server handle cloning it into the player gui container. I’d only rely on server security for my remotes because that’s what matters the most and what I should focus more on. But of course, only whitelisted players can access this said moderation gui which is handled with a local script, not by the server.
I don’t think that any of this would work, don’t hold my word on it however, I don’t think that Server-sided scripts can access PlayerGui of any player at all.
The server can place instances/objects inside the PlayerGui. Furthermore, as long as you store those instances/objects on a variable server side, you can access them after the fact (not advisable).
Hackers cannot create server script, but they can create local scripts. And this is in server script storage, which the hacker cannot access at all. And the reason for the server script is because only server script can access the ServerStorage, which local scripts cannot.
Server sided scripts can access the playerGUI. It’s similar of referencing the folder for leaderstats, which is also accessible to server scripts. Keep in mind that both the Playergui and leaderstats would be parented to the player.