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

Why doesn't my gamepass script work?

Now here is my script (It is supposed to remove the ImageButton and Frame1 which is inside Frame if player doesn't have the gamepass):

id = 382406860 --Gamepass Id

plr = script.Parent.Parent.Parent.Parent
repeat wait() until plr.PlayerGui 
if not plr:PlayerHasPass(id) then
	script.Parent.Parent.Parent.Frame.Frame1:Destroy()
	wait(0.1) 
    script.Parent:Destroy()
end

I'm not sure what went wrong... Does anyone know and can help me?

1 answer

✓ Accepted answer

You dont use player. you use GamePassService. BUUUUTTT lets ditch this method. just DONT. players have to rejoin if you use that. Lets rewrite this with PlayerOwnsAsset.

id = 382406860 --Gamepass Id
local MarketPlace = game:GetService("MarketPlaceService") 

plr = script.Parent.Parent.Parent.Parent
repeat wait() until plr.PlayerGui 
if not MarketPlace:PlayerOwnsAsset(plr, id) then -- use Marketplace, put plr in the parenthese 
    script.Parent.Parent.Parent.Frame.Frame1:Destroy()
    wait(0.1) 
    script.Parent:Destroy()
end

Vote up if i helped! Comment back if it didnt!

4 comments

0

Grammar, m8?

0

?

0

It didn't work again, but there was an output error: 21:47:54.350 - 'MarketPlaceService' is not a valid Service name

0

OH! Caps problem! MarketplaceService*

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