Keep gettin attemp to index nil with UserId

local player = game:GetService("Players").LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")


if MarketplaceService:UserOwnsGamePassAsync(player.UserId,0) then ----
Even = true
else
Even = false
end

I had it in a function at first but even people without the gamepass were getting the tower so i tried to not have it as a function an i get and error on the line marked by —. Dont expect anyone to write a code. Just wanna know where im going wrong

Youre probably using LocalPlayer in a ServerScript which can be only used in LocalScripts

Ahhhh i see now. How would i use it in a module script?

-- LocalScript in StarterPlayerScripts

local PLYRS = game:GetService("Players")
local plyr = PLYRS.LocalPlayer

print(plyr.UserId)