How can I detect if a Player has a Gamepass in a LocalScript?

This is my script so far, but the first part doesn’t work which detects the script.

function Close(player)
   if game:GetService("MarketplaceService"):UserOwnsGamePassASync(player, 5694417) then
      script.Parent.Parent.MainFrame:TweenPosition(UDim2.new(0.5, -320,0.5, -295))
   else
      script.Parent.Parent.Purchase:TweenPosition(UDim2.new(0.5, -320,0.5, -295))	
   end
end

script.Parent.MouseButton1Down:connect(Close)

You are forgetting the extra parts for TweenPosition. Should look like this

Frame:TweenPosition(UDim2.new(0, 5, 0, 5), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)

You can change the easing direction and style, just used as a base.

I am not the best at working with gamepasses, but I think you can only check using normal scripts since LocalScripts are only for the local player and probably can’t check it

Not entirely sure, but that’s ny theory

It’s not that. The tweening actually works, it’s the “UserOwnsGamePass”

You definitely can, I’ve done it before.

1 Like

Okay then

Oh you need to do Player.UserId instead of just Player. @CarlPIandog

2 Likes

“UserOwnsGamePassASync”
check your spellings properly. Lua is case-sensitive.

“UserOwnsGamePassAsync” is the proper spelling.
https://developer.roblox.com/api-reference/function/MarketplaceService/UserOwnsGamePassAsync

4 Likes

A bit off topic, but I wonder why people use ASync over Async…?

From what I understand they aren’t two words, Async = asynchronous (so ASynchronous wouldn’t make sense grammatically). I’m genuinely curious about the naming convention for this.

I think a lot of people don’t actually know that ‘Async’ at the end of the function means ‘Asynchronous’, and they just rope learn the function name as it is - this may lead to capitalization errors and not actually spotting that its wrong.

This is from experience, when I first started I never actually knew what the ‘Async’ meant or did, everything just fell into place and worked.

3 Likes

If they misspell “Async”, then they probably don’t even know what it is/means. (just like what @JohnnyMorganz said.)

They might just be totally clueless and doesn’t know the proper spelling, I can’t blame them for that. “Asynchronous” is not a commonly used word, so it might be very new to some people.

Another thing that could happen is that they might type too fast and lifted their pinky too late which makes capitalization errors more common (I can relate.)

2 Likes