Trying to use clickdetector to prompt Dev Product purchase is returning "Unable to Cast value to Object" error

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to create an in-game shop for my in-game social hangout game, where you can literally buy classic roblox gears, like the Turkey, Tripmine, Pizza, Hyperlaser, you name it!

  2. What is the issue? Include screenshots / videos if possible!
    I keep getting the “Unable to cast value to object” error, although everything might be correct. I don’t know why it is causing this error. I am using a clickdetector to prompt a Developer Product purchase.

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I tried searching up if the clickdetector returned a Character Model or a Player instance as the “player” parameter, seeing if that would work, otherwise I did nothing else.

script.Parent.MouseClick:Connect(function(player)
	-- get marketplace service, and prompt a dev-product purchase
	-- with the model's product-id as the dev product id
	local marketPlaceService = game:GetService("MarketplaceService")
	local player_UserId = player.UserId

	marketPlaceService:PromptProductPurchase(player_UserId, 3314521536)
end)

The error is happening at line 7, and I don’t know whether or not to try to fix the player_UserId object or the integer dev-product item Id.

Any help is appriciated.

Refer to the API next time you run into a similar issue.

The prompt product purchase method requires a player object as its first parameter

Not a player userID?

(ROBLOX CHARACTER LIMIT)

Nope, just the player object itself

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