I have an if then statement, i want the script to work if someone has the gamepass and then it doesnt work if you dont have the gamepass, however the if then statment from the debounce and the else are messing up and combining
heres my script:
local PassId = 4835177
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local BloxyCola = ReplicatedStorage:WaitForChild("????? ???? ???")
local player = game.Players.LocalPlayer
local bloxy = workspace:WaitForChild("itemgiver1")
local debounce = false
bloxy.ClickDetector.MouseClick:Connect(function(player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassId) then --if they have the gamepass
if not debounce then
debounce = true
BloxyCola:Clone().Parent = player.Backpack
bloxy.ClickDetector.MaxActivationDistance=0
bloxy.Transparency=1
for i = 60, 1, -1 do -- give it a 60 second cooldown and show the timer
bloxy.BillboardGui.TextBox.Text = tostring(i)
wait(1)
end
bloxy.ClickDetector.MaxActivationDistance=10
bloxy.BillboardGui.TextBox.Text=(" ") --replaces text and resets everything back to normal
bloxy.Transparency = 0
debounce = false -- allow the script to be run again
else
MarketplaceService:PromptProductPurchase(player.Bloxy, PassId)
end
end
end)
is there anyway to make it where the script can be disabled without debounce or that debounce doesnt have an if then statment?

4 comments
In line 29, it needs to be the Player object, not the UserId.
You have a misplaced end. Try to indent your code properly so the code flow isn't confusing. Move one of the ends you have at the bottom, before the else
thank you, you fixed it! :)
i have one more question, the gamepass says its unavalible. what did i do wrong there?