Script not reading a player's properties

Hello I’m pretty new with scripting, I’ve been trying to learn LUA by reading some articles and mostly messing with scripting on studio. I got a problem that’s been bothering me for hours and I have no idea how to solve it, any help is appreciated.

In my game, I need to run a function when certain properties of the player matches with a table, although the output always shows “attempt to index nil with Name” or “attempt to index nil with Team” or any other property I try to configure, like in the example below.

local function CheckClearance (Player)
	if Departments[Player.Team.Name] == true then
		CheckConfigs()
	elseif Player:GetRankInGroup(MainGroupId.Value) >= Clearance then
		CheckConfigs()
	else return
	end
end

PPrompt1.Triggered:Connect(CheckClearance())
PPrompt2.Triggered:Connect(CheckClearance())

Note that this code is inside a regular script, when I tried the same code with another script, comparing Player.UserId to a NumberValue instace, the script works without any errors.

(Some context, “Clearance” is a number variable, “Departments” is a table containing all team’s names assigned to a true/false value.)

What gives me headaches is that the same system that works on several other scripts won’t work on that one and I have no idea why.

[Edit: apparently it was a mistake I wasn’t really paying attention to, hope this post also helps people new at scripting! Thanks for the reply by the way :slight_smile: ]

PPrompt1.Triggered:Connect(CheckClearance())
PPrompt2.Triggered:Connect(CheckClearance())

You’re calling the functions instead of setting them to the event, remove the ()

PPrompt1.Triggered:Connect(CheckClearance)
PPrompt2.Triggered:Connect(CheckClearance)