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

im having trouble making players buy a product?

so this is the script

local player
script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local productID = 993976756
	player = script.Parent.Parent.Parent.Parent.Parent.Name
	print(player)
	MarketplaceService:PromptProductPurchase(player,productID)
end)

when i run it, it says, unable to cast value to object it happens at the

MarketplaceService:PromptProductPurchase(player,productID)

1 comment

0

Try removing the .Name at the end of player.

1 answer

✓ Accepted answer

So you are giving the MarketPlaceService:PromptProductPurchase a string value of the players name. Instead you should be passing it the actual player.

So in a local script you know how you would say local player = game.Players.LocalPlayer.

You would use the player instead of the players name.

I'm not sure where this script is but if you put the actual player instead of the name you should be good.

If you remove .Name It should solve your issue. If that is indeed the player.

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