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 3 years ago

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)
0
Try removing the .Name at the end of player. 9mze 193 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 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