How can I prevent this `index local` situation?

NOTE: This script does work! I only have this error when I use a BindableEvent.

Achieve

So, what i’m doing is making an admin module system that has to be ran every single time a certain event/script is ran. This is due to exploiters ruining my game by using my own Control System against me.

Issues

image

The reason this happens

As you can see, I have two different scripts that are connected through a BindableEvent.
When I fire the Script #1, the #2 script doesn’t get a UserId value and ends up causing the error above which stops the script from completing entirely.

Script #1

image

Script #2

image

Solutions

I do not know any solutions to this as I do believe this to be a very unique case compared to others.

The Command

if adminCheck.Activate(plr) then
end

The Module Script

--[Made By MillerrIAm]--
--------[Variables]-------
local player = game:GetService("Players")
---------[Admins]--------
adminIDs = {678299,4947564}
--[[UserIds in order = {"MillerrIAm","NemesisY2J"}]]
--------[Main Code]------
local adminCheck = {}

function adminCheck.Activate(plr)
		for i,Admin in ipairs (adminIDs) do
			if plr.UserId == Admin then
				print("Admin Started")
				return true
			end
		end
	end

return adminCheck

Thank you for any help you can give me.

Can you show where you fire the BindableEvent mentioned in Script #2? You most likely forgot to fire it with arguments.

Here you go.
This is the BindableEvent that gets fired.
image
This is the script that responds to the BindableEvent.
image

I know that technically, I could remove the adminCheck from the BindableEvent script as this is only accessible through another Server Script which exploiters can’t access nor create.
I just like being as safe as possible.

You could just remove the adminCheck.Activate as you stated since the client won’t be able to fire the BindableEvent, or you could change the arguments of Lights:Fire to include plr.

1 Like