So here is my code, I don't know what is wrong with it.
local Player = game.Players.LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassId = 10425066
-- Directly after an in-game purchase with MarketplaceService:PromptGamePassPurchase(Player, GamepassId)
script.Parent.MouseButton1Click:Connect(function()
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) and Player.leaderstats.Points.Value > 499 then
game.Workspace:WaitForChild(Player.Name).HumanoidRootPart.CFrame = workspace.TeleportTo1
print("player owns gamepass")
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(Player, GamepassId)
print ("prompted purchase")
end
end)
Getting an error about: " 19:01:42.467 - Players.WishXVI.PlayerGui.ScreenGui.Teleframe.TextButton.Script:8: attempt to index nil with 'UserId'""

2 comments
is this a local or server script?
ServerScript. In the error, you can see "TextButton.Script", which is the default name for a ServerScript. LocalPlayer can only be used in LocalScripts.