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

PlayerOwnsGamepassAsync is not a valid member of MarketplaceService?

what is wrong here? trying to fix a tycoon kit script, the original was PlayerOwnsAsset and now gps arent assets heres that one thing of code, pls help idk whats wrong btw im new to scripting so dont rek me

			v.Head.Touched:connect(function(hit)
             local player = game.Players:GetPlayerFromCharacter(hit.Parent)
				if v.Head.CanCollide == true then
					if player ~= nil then
						if script.Parent.Owner.Value == player then
							if hit.Parent:FindFirstChild("Humanoid") then
								if hit.Parent.Humanoid.Health > 0 then
									local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
									if PlayerStats ~= nil then
										if (v:FindFirstChild('Gamepass')) and (v.Gamepass.Value >= 1) then
											if game:GetService("MarketplaceService"):PlayerOwnsGamepassAsync(player,v.Gamepass.Value) then
												Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
											else
												game:GetService('MarketplaceService'):PromptPurchase(player,v.Gamepass.Value)
											end
										elseif (v:FindFirstChild('DevProduct')) and (v.DevProduct.Value >= 1) then
											game:GetService('MarketplaceService'):PromptProductPurchase(player,v.DevProduct.Value)
										elseif PlayerStats.Value >= v.Price.Value then
											Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
											Sound(v, Settings.Sounds.Purchase)
										else
											Sound(v, Settings.Sounds.ErrorBuy)
										end
									end
								end
							end
						end
					end
				end
			end)
			end
		end)
	end

1 answer

✓ Accepted answer

There are two problems with your code.

First of all, it's UserOwnsGamePassAsync, not player, and with a capital G. You should use it like this.

game:GetService('MarketplaceService'):UserOwnsGamePassAsync(player.UserId, v.Gamepass.Value)

Also, as shown in above, you need to provide the UserId instead of the player object for UserOwnsGamePassAsync.

1 comment

0

TYSM dude <333333

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