Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Gojinhan 353 Moderation Voter
5 years ago

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)

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

1 answer

Log in to vote
1
Answered by
ScuffedAI 435 Moderation Voter
5 years ago
Edited 5 years ago

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:

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

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.

01local admins = {'39021093','1329889','31239'} -- example of admins
02local isAdmin = false
03for i = 1,#admins do
04    local admin_id = admins[i]
05    if player.userId == admin_id then
06        isAdmin = true
07        break
08    end
09end
10 
11if isAdmin then
12    print('Display your gui.')
13end

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

0
Thank you I've been trying to figure this out forever. Gojinhan 353 — 5y
Ad

Answer this question