How to test if someone ownes a gamepass (will this work?)

Hello there thank you for coming here, I was wondering if this code would work and how I would test if it would work.

If you need to see more of the script just say it.

1 Like

I’m a bit confused here.

  1. Why are you creating a variable that is just the already-existing value of something you’re checking for?
    image
  2. You’re not giving much context here; I’m assuming this is a TDS game where you can buy a ‘God’ tower with a certain gamepass, to which it could theoretically work but I have no idea how the Client is firing the RemoteEvent.
  3. There is a redundant parameter “UserId” from this RemoteEvent when it can just be grabbed from the player’s UserId. The only use I can really think of this for is gifting towers? Unless you can gift towers this is an unnecessary use of parameter space for Events.
1 Like

Thank you for taking your time to help me.

Here is the local script that fires the event.

And the updated server side script (with what you pointed out):

I am sorry for not being clear enough from the start.

2 Likes

Other than a slight error where to speed up performance you should’ve used
player.UserId instead of Players:GetUserIdFromNameAsync(player) that should work as long as the table is being used correctly (I’m assuming it’s a table of data of the user’s towers that gets saved?)

1 Like

Thats correct.

I changed

to this:

Thank you for helping me figure this out.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.