-------------------------- local MarketplaceService = Game:GetService("MarketplaceService") local buyButton = game.Workspace.TheLobby.Shop.DPVEND.BuyButton.SurfaceGui.TextButton local productId = 19661235 local player = script.Parent.Parent buyButton.MouseButton1Click:connect(function() MarketplaceService:PromptProductPurchase(player, productId) end) MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased) if isPurchased then -- user purchased product, show confirmation box wait(0.1) player.Status2.DP.Value = player.Status2.DP.Value + 125 else -- user didn't purchase product, do other stuff end end)
Exactly what title says. It gives EVERYONE in the server 'DP' instead of just the purchasing person. Does anyone know a fix to this?
You can simply do that by accesing all children of Players service, and a for loop.
Code would look something like this and should be placed in part where player purchases the Dev. Product:
for i, v in pairs(game.Players:GetChildren()) do v.Status2.DP.Value = v.Status2.DP.Value + 125 end
To clarify some things:
:GetChildren() puts all children of Players into a table. If you have players named "Steve" and "Peeve" then the table would look something like this '{game.Players.Steve, game.Players.Peeve}'
i and v are used as Index (key) and Value. Index (key) is position of a value in table, and Value is.. a value (in this case an Object). We don't need Index in this case.
for loop goes through all of the values of the table (which we made with :GetChildren())
And I assume you know the rest of the code which makes Player's Status2 value rise for 125.