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)
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
Change ResetOnSpawn to false on the ScreenGui.
Also, your loop doesn’t even do that. It stops once the DevGui is parented.
If you want to clone the GUI every time the player respawns:
-- This code is better than any of the other posts in this thread
local devs = {1998082358, 302070682, 1403193781, 105842946, 1467262997, 70025961}
local gui = game:GetService('ServerStorage').DevGui
local function playerAdded(plr)
if table.find(devs, plr) then
gui:Clone().Parent = plr.PlayerGui
if gui.ResetOnSpawn then
plr.CharacterAdded:Connect(function()
gui:Clone().Parent = plr.PlayerGui
end)
end
end
end
local players = game:GetService('Players')
players.PlayerAdded:Connect(playerAdded)
for _, player in ipairs(players:GetPlayers()) do
playerAdded(player)
end
the script inside the gui also broken for sure
The reset on spawn property is false so I don’t need this.
this type of scripts are not that safe. some exploiters can still accsess it using dark dex.
What about putting it into ServerStorage (so clients can’t see it) and cloning it into PlayerGui from there?
Thanks everyone who helped, especially @AridFights1 for the simple solution, thanks a lot everyone have a great day ahead!
yeah this might block some exploits but exploits with script compilers still can access to server stuff somehow.
Then you can remove the CharacterAdded portion, but the rest of the code is still valid.