ReplicatedStorage.PlayerList:824: attempt to index nil with 'Event'

I’ve recently wrapped my corescript variables within a pcall, but now due to this, it seems to be setting the corescript status as nil, and because of this, it’s preventing a module to run. I’m wondering if it has to do with the fix…

wrapped variables

local blockedUsers = nil
local playerBlocked = nil
local playerUnblocked = nil
local playerFriended = nil
local playerUnfriended = nil

pcall(function()
	blockedUsers = SGS:GetCore('GetBlockedUserIds')
	playerBlocked = SGS:GetCore('PlayerBlockedEvent')
	playerUnblocked = SGS:GetCore('PlayerUnblockedEvent')
	playerFriended = SGS:GetCore('PlayerFriendedEvent')
	playerUnfriended = SGS:GetCore('PlayerUnfriendedEvent')
end)

the problematic code

guiConnections[#guiConnections + 1] = PS.PlayerAdded:Connect(onPlayerAdded)
guiConnections[#guiConnections + 1] = PS.PlayerRemoving:Connect(onPlayerRemoving)
guiConnections[#guiConnections + 1] = TMS.ChildAdded:Connect(onTeamAdded)
guiConnections[#guiConnections + 1] = TMS.ChildRemoved:Connect(onTeamRemoved)

guiConnections[#guiConnections + 1] = playerBlocked.Event:Connect(function(blockedPlayer)
	local pData = playerData[find(playerData, blockedPlayer)] 
	blockedUsers[#blockedUsers + 1] = blockedPlayer.UserId

i’m still trying to find a solution, but everything i’ve attempted had no results.

By wrapping those calls with pcall, you’re silencing any errors that may be occurring. For some reason, playerBlocked is nil, which is probably happening because one of your SGS GetCore calls are throwing an error. Remove the pcall to find the error (or catch the error as the return of the pcall).

image
ah… this is the error that is returned after removing the pcall… how would I go about fixing this? I’d assume I’d make it loop until the error is rectified, but since I’m new at scripting,. I am unsure as to how I’d go about doing this.

possibly with a pcall, which is what I’ve tried, which made it so that playerBlocked returns a nil value.