Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

added a gamepass check and script broke?

this is a script that i've been posting all day. I finally went to add a gamepass checker to it and now it wont work

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
script.Parent.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:PromptPurchase(player, PassId) --if they dont have the gamepass ask them to buy it
end
    end
end)


how could I fix this? I don't see any red lines under anything so I'm not sure where it's falling apart

1 answer

✓ Accepted answer

###Your problem is on line 10. The first argument to UserOwnsGamePassAsync is an int64 UserId, and you passed the Player object instead. To fix that:

if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassId) then

4 comments

0

ty so much. you helped me a ton throughout this script and it wouldn't exist w/o you! :)(you basically made it)

0

hey, I have another question. Why wont my else statement work?

0

Because it's inside the "if not debounce then" if statement.

0

is there a way that i could use debounce/disable the script if i dont use that statment

This discussion is preserved as it was. New answers, comments, and votes are closed.