Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hi, regardless of how I write it, my admin gui script wont work?

To be clear, the issue is that the script gives me an admin gui. But i've tested it with alts, friends, many people not on the admin list and they still get the gui.. Here's the code (It's just one script in ServerScriptService)

game.Players.PlayerAdded:connect(function(player)
	if player.userId == game.CreatorId or "320691098" or "676065804" then
		game:GetService("ServerStorage").ToysGui:Clone().Parent = game.Players[player.Name].PlayerGui
	end
end)

1 answer

✓ Accepted answer

The IF statement that you created in line 2 became true because you didn't compare each userId individually. What you have to do instead is the following:


if player.usedId == userid_1 or  player.usedId == userid_2 then -- and so on...
	print('Display some fancy gui')
end

Writing like I just did above might get the job done, but it would be pretty inefficient to have to write a comparison for each single admin. I would suggest that you create a table that contains all of the user id.

local admins = {'39021093','1329889','31239'} -- example of admins
local isAdmin = false
for i = 1,#admins do
	local admin_id = admins[i]
	if player.userId == admin_id then
		isAdmin = true
		break
	end	
end

if isAdmin then
	print('Display your gui.')
end

This way you won't have to write a comparison for every admin.

1 comment

0

Thank you I've been trying to figure this out forever.

This discussion is preserved as it was. New answers, comments, and votes are closed.