I am getting this error and I do not know what I have mistaken, please help!
The error:
Script:
local plr2 = game:GetService("Players").LocalPlayer
local Player = game:GetService("Players").LocalPlayer.UserId
local gamePassID = 1340906699
button.MouseButton1Click:Connect(function()
MarketplaceService:PromptPurchase(Player, gamePassID) -- Line 13
Purchase:FireServer(plr2)
end)
It’s because you’re trying to pass in an integer into an argument of the PromptPurchase method that requires an instance of a Player object. The solution is to just remove the .UserId property from the Player variable. However, since you’ll now have 2 variables both assigned to the player, you can just remove it like so:
local Player = game:GetService("Players").LocalPlayer
local gamePassID = 1340906699
button.MouseButton1Click:Connect(function()
MarketplaceService:PromptPurchase(Player, gamePassID)
Purchase:FireServer(Player)
end)
I’m not sure what Purchase is, I’m trusting you have a RemoteEvent variable stored in the script somewhere.
Also for future reference, you don’t need to re-index .LocalPlayer and get the UserId in a separate variable like that. You should do this from now on:
local Player = game:GetService("Players").LocalPlayer
local plr2 = Player.UserId