What do you want to achieve? Keep it simple and clear!
I want to make an admin Gui visible to only me.
What is the issue? Include screenshots / videos if possible
Serverscritpt:
local starterGui = game:GetService("StarterGui");
local screenGui = starterGui:FindFirstChild("ScreenGui");
local img = screenGui.ImageLabel;
local players = game:GetService("Players");
local player = players.LocalPlayer;
local UserId = player.UserId;
if UserId == 120640653 then
screenGui.Enabled = true;
end;
How do I do this?
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Because this is a regular script, you cannot get the LocalPlayer, you have to use a localscript instead to get the LocalPlayer property of the Players service
If you’re worried about that, then you can use PlayerAdded instead to see if the UserId of the player who just joined is equal to the specified id and just enable the gui from their playergui
players.PlayerAdded:Connect(function(player)
If player.UserId == 120640653 then
local guis = player:WaitForChild("PlayerGui")
guis.ScreenGui.ImageLabel.Enabled = true
end
end)
I don’t believe the event will delay since it runs whenever a player joins your game, the only thing that you need to do is wait for their PlayerGui to load before doing anything
Make a script in ServerScriptService, called it Admin or anything you want.
In the script decide whether you want it to be based of the Players Name or Players Id
Create a Table
AdminTable = {"IfYouChooseName",234234234234,23423423424} -- Do Name or Id
Then you when a player connects you want to check whether they have admin
game:GetService("Players").PlayerAdded:Connect(function(Player)
for _, admin in pairs(AdminTable) do -- Loops through the admin table
if admin == Player.Name or admin == Player.UserId then
player.PlayerGui.NameOfScreenGui.Enabled = true -- Enable the frame
end
end
end)
I hope this helps, if you have any issues then let me know.
local adminTable =
{
120640653,
1
}
game:GetService("Players").PlayerAdded:Connect(function(Player)
for _, admin in pairs(adminTable) do
if admin == Player.UserId then
Player.PlayerGui.ScreenGui.Enabled = true;
end;
end;
end);