[Solved] having trouble with players buying an item?
Asked by
4 years ago Edited 4 years ago
so here is the code
01 | local player = script.Parent.Parent.Parent.Parent.Parent |
02 | script.Parent.MouseButton 1 Click:Connect( function () |
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
04 | local productID = 994379939 |
05 | MarketplaceService:PromptProductPurchase(player,productID) |
07 | MarketplaceService.PromptProductPurchaseFinished:Connect( function (player, productID, isPurchased) |
08 | if isPurchased = = true then |
09 | player.leaderstats.lives.Value = player.leaderstats.lives.Value + 10 |
10 | print ( "suggsessful purchase" ) |
12 | print ( "Player did not purchase product" ) |
when i run it and buy it there is an error saying:
Script:9: attempt to index number with 'leaderstats'
it happens at line 9 for some reason its not the line itself because ive put it at the top and that part works fine
edit: it works fine i solved it first person to say any answer gets a free point or whatever
01 | local player = script.Parent.Parent.Parent.Parent.Parent |
02 | script.Parent.MouseButton 1 Click:Connect( function () |
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
04 | local productID = 994379939 |
05 | MarketplaceService:PromptProductPurchase(player,productID) |
07 | MarketplaceService.PromptProductPurchaseFinished:Connect( function (player, productID, isPurchased) |
08 | if isPurchased = = true then |
09 | script.Parent.Parent.Parent.Parent.Parent.leaderstats.lives.Value = script.Parent.Parent.Parent.Parent.Parent.leaderstats.lives.Value + 10 |