Gamepass GUI Trouble

Hello there,

My gamepass GUI I made, which lets you get the Gamepass tool if you bought it, instead of the script that automatically gives you it, so your load out doesn’t have 10 tools, is currently not working. The problem is, I’ve tried it out in both game and studio and it’s giving me all of the tools, regardless if I have the gamepass or not. Does anyone know what the problem is?

If you want to take a look at it I’ve included both the script and gamepass UI.
PleaseFix.rbxm (30.2 KB)

It’s a bit late for me so I skimmed through the scripts and couldnt find any issues other than the fact that you are using the ID of a decal to test it.
Are you certain this is how you intended to test your scripts?

Have in mind that when you switch your ID to the gamepass ID you’ll have to use the MarketplaceService’s dedicated method to verify that the player owns the pass

game.MarketplaceService:UserOwnsGamePassAsync(player, gamepassId)

a few more things I’d like to recommend:

  • Indent your code, its really hard to read when someone doesnt use tab or spaces

  • Dont use a different script for each button, is much easier if you have a single LocalScript outside the UI (I usually use PlayerScripts) and loop through all the buttons that have the same functionality and connect them to a function. This way you reutilize code and you dont have to edit all your scripts each time you want to make a small change.

2 Likes

Actually I am using a gamepass ID from my game V

I guess it has the exact same number as a decal. Is that possible?

Yes, gamepasses are a different asset so they can have same ID. Try using the marketplace method for gamepasses and see if that fixes the problem.

If it doesn’t work I’d recommend adding prints across the script to see where it’s failing

1 Like

I don’t mean to sound dumb but where would I put the marketplace code in. In my validator script or in the textbutton script

Make it a variable, example:

local GetInfo = MarketplaceService:GetProductInfo(1234567, Enum.InfoType.GamePass)

print(GetInfo.Name)
print(GetInfo.IconImageAssetId)

Also you would put this in the script that changes the image ID.

(Beware, getting GamePass image IDs from MarketplaceService has a high tendency not to function but I have noticed a difference in the API of all my gamepasses, especially in the ImageIconAssetId area, so this could be functioning properly now)

1 Like

Should I put this in my textbutton script or my Gamepassvalidator script that goes in serverscriptservice

1 Like

Which script do you want to update the image? I’ve not looked at the file because I’m on mobile. If you want efficiency I recommend handling all your GUI elements in one script called handler that is placed as a child in the ScreenGui to stop confusion with what scripts you need and for ease of access in the future.

1 Like

Currently I have a local script inside each textbutton that gives you the tool, then I have a script in serverscriptservice for it to work, since my game is filtering enabled. I just need it the gui to where, if you bought a gamepass, then you click the button and it’ll give you the tool. So I don’t have to use the gamepass giver script that does it automatically.

1 Like

Instead of having a local script in each text button, use one script that works exactly like the others but instead of script.Parent.MouseButton1Click just change it to script.Parent.TextButton1 etc. Using one script to manage everything will make your life 100% more easier especially if you plan on learning data store.

1 Like

Alright so i think i know what your problem is it states in output that PlayerOwnsAsset is not a valid member of gamepassservice so that means you’re not using the correct thing try using this:

2 Likes

Should this be put in the local script in my textbutton?

yes

Should I keep the

local gamePassValidator = game.ReplicatedStorage:WaitForChild("GamePassValidator")

In my script as well

yeah its fine just that you want to change out PlayerOwnsAsset with the thing i sent you

2 Likes

I have a few more questions so I sent you a request on discord.

Alright