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

Instance not cast to int64 error in purchase handler?

Hello, im trying to make a purchase manager and everything works fine in it BESIDE the gamepasses when checking if UseOwnsGamePassAsync i get Instance not cast to int64 error help need thanks!

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"):UserOwnsGamePassAsync(player,v.Gamepass.Value) then
											Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
										else
											game:GetService ("MarketplaceService"):PromptGamePassPurchase(player,v.Gamepass.Value)
										end

V is just a value that is open for whenever its needed

1 answer

Check the documentation for UserOwnsGamePassAsync.

The first argument is a user id, not a Player instance.

:UserOwnsGamePassAsync(player.UserId, v.GamePass.Value)

2 comments

0

Thanks for the quick answer ill try it out

0

I get the error attempt to index field 'UserId' (a number value)

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