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
10 years ago
--------------------------
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?

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

1 answer

Log in to vote
0
Answered by
Tiranin 45
10 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:

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.

Ad

Answer this question