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

Developer Products - Gives EVERYONE in the server points and not only the person who purchased?

Asked by
3dsonicdx 163
11 years ago
01--------------------------
02local MarketplaceService = Game:GetService("MarketplaceService")
03local buyButton = game.Workspace.TheLobby.Shop.DPVEND.BuyButton.SurfaceGui.TextButton
04local productId = 19661235
05local player = script.Parent.Parent
06buyButton.MouseButton1Click:connect(function()
07MarketplaceService:PromptProductPurchase(player, productId)
08 
09 
10 
11end)
12 
13MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased)
14if isPurchased then
15-- user purchased product, show confirmation box
View all 22 lines...

Exactly what title says. It gives EVERYONE in the server 'DP' instead of just the purchasing person. Does anyone know a fix to this?

0
Is this GUI? If so use LocalPlayer. systematicaddict 295 — 11y
0
Uhm, it's a SurfaceGUI button. If you read carefully, it's one of those clickable things(SURFACEGUI) 3dsonicdx 163 — 11y

1 answer

Log in to vote
0
Answered by
Tiranin 45
11 years ago

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:

1for i, v in pairs(game.Players:GetChildren()) do
2    v.Status2.DP.Value = v.Status2.DP.Value + 125
3end

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.

Ad

Answer this question