heres a script i got and tried to edit, i want to make it where you can get the item onclick if you have the gamepass but if you dont then it asks you to purchase it
local PassId = script["4835177"]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local BloxyCola = ReplicatedStorage:WaitForChild("Bloxy Cola")
local player = game.Players.LocalPlayer
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if MarketplaceService:UserOwnsGamePassAsync(player, PassId) then -- if they have the gamepass then they get it
BloxyCola:Clone().Parent = player.Backpack
for i = 60, 1, -1 do -- give it a 60 second cooldown and show the timer
script.Parent.BillboardGui.TextBox.Text = tostring(i)
wait(1)
else
game:GetService("MarketplaceService")PromtPurchase(player,id) -- if they dont have the gamepass ask them to buy it
end
end
end)
the script doesn't work at all and I don't know why. could someone please point out some mistakes that stop it from working? any help is very appreciated:)

4 comments
What exactly is PassId?
It's the gamepass ID
Make sure its in a server script if not alread
i moved it into serverscriptservice and changed all of the directories. no luck :(