#When a player joins, check if they're in a table

39 messages · Page 1 of 1 (latest)

robust shale
#

What does plr:GetRankInGroup(...) print?

#

does it print fine 3?

#

debug is always helpful

undone rampart
#

in your first script use userids and iterate through all the tables contents using a for loop so its more secure

#

heres an example

local admins = {-1,-2} -- example ids for studio tests (player 1 and 2)

game.Players.PlayerAdded:Connect(function(player)
    for _, adminId in ipairs(admins) do
        if player.UserId == adminId then
            print('admin has joined the game: ',player.Name)
            break -- end the loop when their id is found
        end
    end
end)
robust shale
#

"it doesn't work"
I would like to know what does print(plr:GetRankInGroup(14998554)) return This is calling "debug", easier to find out what ain't working... ._.

#

This is why im asking you please do.

#

Add the line code

#

Else use the first method

#
local auth = {"Freddocin", "others", "Player1"}

game:GetService("Players").PlayerAdded:Connect(function(ply)
    if table.find(auth, ply.Name) then
        print("There you go")
    end
end)
#

So the script is a local script and in ServerScriptService?

#

Yea that won't works

#

this events are server side

#

You gotta put inside server side, not localscript

#

If you need this run on Localscript

#

then dont use the event at all

undone rampart
#

but exploiters can just modify the code and make it appear as if they were an admin

#

if you did it in a local script

#

stfu

#

they could remove the if statement to check if they're in a group

#

if done in a localscript

robust shale
#
local auth = {"Freddocin", "others", "Player1"}
local player = game.Players.LocalPlayer
if table.find(auth, player.Name) then
        print("There you go")
end

But you can't use GetRankInGroup, i belive, its server side, since it requried "http" calls.

undone rampart
#

well yes

#

but they could execute the exact code

#

without the if statement

#

most can

#

use a serversided script

#

in serverscriptservice

robust shale
#

remoteEvent, more secure its bindable event i belive

undone rampart
#

but using userids because it cant be changed

#

aight

#

if its using a serverscript they cant be modified btw

#

same

robust shale
#
auth[table.find(auth, ply.Name)]

table.find return index

#

Somethings like that?

local function add(player)
    table.insert(auth, player.Name)
end

local function rem(player)
    if table.find(auth, player.Name) then
        table.remove(auth, table.find(player.Name))
    end
end

local function set(player, index)
    table[index] = player.Name
end
deep python
#

Not true at all, RemoteEvents are not insecure or secure by themselves, it mostly depends on the server-side code and data validation, in this case the code can be completely secure as long as you get the player information from the server

#

You can do that by storing a list (table) of the UserIds (not names as they can be changed) of the players, then using the function table.find(), as suggested by Freddo, to know if a certain player is in it

#

You already have the player from the PlayerAdded event (?)