Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

im having trouble making players buy a product?

Asked by 5 years ago

so this is the script

1local player
2script.Parent.MouseButton1Click:Connect(function()
3    local MarketplaceService = game:GetService("MarketplaceService")
4    local productID = 993976756
5    player = script.Parent.Parent.Parent.Parent.Parent.Name
6    print(player)
7    MarketplaceService:PromptProductPurchase(player,productID)
8end)

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

1MarketplaceService:PromptProductPurchase(player,productID)
0
Try removing the .Name at the end of player. 9mze 193 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

Ad

Answer this question