Hey guys,
So I need a dev only gui. What i tried was to put a script in sss and on the playeradded check if the player user id matches the user id of a dev, if it matches i clone the gui frm srvr storage to the playergui. but its giving the gui to everyone. had to put it in srvr storage to prevent hackers frm getting it. help would be appreciated, thanks.
We need to see the code you have to be able to identify the issue you’re having as to why your code is giving it to everyone regardless
game:GetService(“Players”).PlayerAdded:Connect(function(plr)
if plr.UserId == yourUserId then – enter your Id here
script.Gui:Clone().Parent = plr.PlayerGui – enter way to your gui
end
end)
It should not give the gui to other players
@EmbatTheHybrid @iamajust heres the script:
--anirudh851
--do not touch
local admins = {1998082358, 302070682, 1403193781, 105842946, 1467262997, 70025961} --fourth is da melon
game.Players.PlayerAdded:Connect(function(player)
if admins[player.UserId] then
local cloneGui = game.ServerStorage.StaffGui:Clone()
cloneGui.Parent = player.PlayerGui
end
end)
In your case that’s not how you check if a userid is in a table, that’s for dictionaries whose value is truly, use table.find
--anirudh851
--do not touch
local admins = {1998082358, 302070682, 1403193781, 105842946, 1467262997, 70025961} --fourth is da melon
game:GetService("Players").PlayerAdded:Connect(function(player)
if table.find(admins, player.UserId) then
game:GetService("ServerStorage").StaffGui:Clone().Parent = player.PlayerGui
end
end)
And for your case of it giving it to everyone, did you put it in StarterGui?
it gave the gui to my main (thats expected) testing on my alt.
it also gave to my alt whos user id isnt in the table
Is the gui in StarterGui by any chance?
nah. checked it its in srvr storage
Is there anything else adding it to everyone then, such as another script? If it’s still giving it to everyone even though the code should only give it to admins in the table since the code looks fine, then it’s either another script or something else.
Perhaps try it in a blank baseplate, only copying the cloning script and the staffgui to see if it’s an issue with the code?
theres no other script at the point handling the distribution of the gui. I’ll still check all once again tho
Nope. Checked all, none of the scripts other than this is handling the gui.
There:
local admins = {1998082358, 302070682, 1403193781, 105842946, 1467262997, 70025961}
local gui = game.ServerStorage.DevGui
local runservice = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
for i = 1, #admins do
if admins [i] == player.UserId then
repeat
runservice.Stepped:Wait()
gui:Clone().Parent = player:WaitForChild("PlayerGui")
until player:WaitForChild("PlayerGui"):FindFirstChild("DevGui")
end
end
end)
end)
There’s a post regarding this
Edit: If you don’t want to download it then try this
local devs = {
-- Ids here
}
local gui = game.ServerStorage:WaitForChild("StaffGui") -- Put the path here
game.Players.PlayerAdded:Connect(function(plr)
for _, dev in pairs(devs) do
if plr.UserId == dev then
gui:Clone().Parent = plr:WaitForChild("PlayerGui")
end
end
end)
Why do you use a Stepped loop for parenting a GUI to someone’s PlayerGui?
You are aware that one clone is enough right?
to wait faster (30 limits AAAAAAAAAAAAa)
What I’m saying is you don’t need to wait or use a loop at all.
but If I dont use loop the gui will disappear whenever player respawned