I created this script to make that roblox purchase screen appear for those who do not have a GamePass and DO NOT appear for those who have it. The problem is that this error is showing "Unable to cast value to Object, on line 21" and the screen sells does not appear.
01 | local Gamepass 1 = workspace.LEVEL 2 _MAP.GamePasstouch |
02 |
03 |
04 | local Id 1 = 2544515 |
05 |
06 |
07 | local debounce = false |
08 | Gamepass 1. Touched:Connect( function (t) |
09 | if t.Parent:FindFirstChild( 'Humanoid' ) then |
10 | if debounce = = false then |
11 | debounce = true |
12 | local haspass = false |
13 | local name = t.Parent.Name |
14 | local b = game.Players:FindFirstChild(name) |
15 | local success, message = pcall ( function () |
01 | local Gamepass 1 = workspace.LEVEL 2 _MAP.GamePasstouch |
02 | local Id 1 = 2544515 |
03 |
04 | local debounce = false |
05 | Gamepass 1. Touched:Connect( function (t) |
06 | if t.Parent:FindFirstChild( 'Humanoid' ) then |
07 | if not debounce then |
08 | debounce = true |
09 | local haspass = false |
10 | local name = t.Parent |
11 | local b = game.Players:GetPlayerFromCharacter(name) |
12 | local success, message = pcall ( function () |
13 | haspass = game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(b, Id 1 ) |
14 | end ) |
15 | if not haspass then |
I found your error, when using "PromptGamePassPurchase", you have to pass the player as the first argument, not the UserId!