Attempt to index nil with "Yit"

I’m working on some sort of panel and auth system right now for fun however I got a problem: every time I run the remote event there’s a error.
Error:

ServerScriptService.Yit.Engine:4: attempt to index nil with 'Yit'

Code:

local settings = require(game:GetService("ServerScriptService").Yit.Settings)

game:GetService("ReplicatedStorage").YitRemotes.checkAuth.OnServerEvent:Connect(function(auth,plr)
		local AC = plr.PlayerGui.Yit.AccessCheck
		AC.Visible = true
		plr.PlayerGui.Yit.AuthFrame.Visible = false
		task.wait(2)
		if auth == settings.AuthCode then
			AC.AuthCode.status.Text = "🟢 Passed"
			AC.AuthCode.status.TextColor3 = Color3.fromRGB(55, 255, 0)
		else
			AC.AuthCode.status.Text = "🔴 Failed"
			AC.AuthCode.status.TextColor3 = Color3.fromRGB(255, 0, 0)
		end
		task.wait(2)
		if not table.find(settings.Admins, plr.UserId) then 
			AC.AdminPermCheck.status.Text = "🔴 Failed"
			AC.AdminPermCheck.status.TextColor3 = Color3.fromRGB(255, 0, 0)
	elseif table.find(settings.Admins, plr.UserId) then
			AC.AdminPermCheck.status.Text = "🟢 Passed"
			AC.AdminPermCheck.status.TextColor3 = Color3.fromRGB(55, 255, 0)
		task.wait(2)
		if plr.AccountAge >= 60 then
				AC.AccountCheck.status.Text = "🟢 Passed"
				AC.AccountCheck.status.TextColor3 = Color3.fromRGB(55, 255, 0)
			else
				AC.AccountCheck.status.Text = "🔴 Failed"
				AC.AccountCheck.status.TextColor3 = Color3.fromRGB(255, 0, 0)
			end 
			if AC.AccountCheck.status.Text == "🔴 Failed" or AC.AdminPermCheck.status.Text == "🔴 Failed" or AC.AuthCode.status.Text == "🔴 Failed" then
				AC.result.Text = "Access Result: Failed"
				AC.result.TextColor3 = Color3.fromRGB(255, 0, 4)
				task.wait(2)
				AC.Visible = false
				plr.PlayerGui.AuthFrame.Visible = true
			else
				AC.result.Text = "Access Result: Passed"
				AC.result.TextColor3 = Color3.fromRGB(55, 255, 0)
				AC.Visible = false
			    task.wait(3)
			    -- show AP
		end	
	end
end)

can you send the ss or explorer of that part ?

@kittyPGR This is line 4, you don’t need the explorer.

you have the two parameters backwards on…

game:GetService(“ReplicatedStorage”).YitRemotes.checkAuth.OnServerEvent:Connect(function(auth,plr)

have it be function (plr, auth)

always the first parameter of OnServerEvent:Connect will be the player who’s client sent the event.
so if plr is a value you are sending and is not the same as the client that sent the event, you might need to have it be function(sentFromPlayer, plr, auth) would help to see the code where the event is being fired from, from the client.

1 Like