Hello, I am a noob at LUA, I tried this in order to make a ScreenGui/TextButton offer a gamepass On-Click.
local Player = game:GetService("Players").LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService") local Button = script.Parent
local function onClicked() MarketplaceService:PromptGamePassPurchase(Player,6255391) end
Button.MouseButton1Click:Connect(onClicked)
But I get this error message when I test it:
Error MarketplaceService:PromptGamePassPurchase() player should be of type Player, but is of type nil
Does anyone know how to fix it?

All you have to do now is just copy the code from the previous script, paste it over to the local script, and then delete the previous script. Your issue should be fixed!