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)

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

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:


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.

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

Answer this question