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

why is promptpurchase prompting everyone in game? [SOLVED]

Asked by 10 years ago

i am using promptproduct purchase for developer products i'm selling and promptpurchase for me gamepasses. i'm getting complaints from players about being prompted to purchase my game passes, but i don't have any auto-prompts running, only clickdetectors to prompt whoever clicks it. i've been selling developer products for awhile and haven't had complaints about being prompted, but i just added gamepasses to be purchased ingame and now i'm getting the complaints about being prompted to buy a pass, so i assume it's only doing this when a player clicks to purchase a gamepass, and not a developer product. the only difference between the two one uses promptproductpurchase and the other uses promptpurchase. i have the prompt script in a serverscript located inside player gui. this is what i'm doing, what dshould i do differently?

1buyButton.MouseClick:connect(function(player)
2    game:GetService("MarketplaceService"):PromptPurchase(player, productId)
3end)

EDIT

here's the test place with a copy of the scripts.

I've moved the prompt script to a local script inside of playergui

here's my code

01--this is the localscript
02 
03 
04 
05local assetid
06local player
07 
08 
09local function showinfoproduct()
10local store = script.Parent.store
11local image = store.frame.frame.Thumbnail
12local name = store.frame.frame.ItemName
13local price = store.frame.frame.CurrencyAmount
14local price2 = store.frame.frame.CurrencyAmount2
15local disc = store.frame.description
View all 61 lines...

with this above, in a local script it is prompting everyone not just the player who clicks. and it shows the description gui to all players

but if i move it to a serverscript it only prompts the player who clicked. but it opens the description gui on all players.

01--this is the serverscript
02 
03 
04 
05 
06local assetid
07local player
08 
09 
10 
11local function showinfoasset()
12local store = script.Parent.store1
13local image = store.frame.frame.Thumbnail
14local name = store.frame.frame.ItemName
15local price = store.frame.frame.CurrencyAmount
View all 90 lines...

ok fixed now. I've pasted the corrected script below.

01local assetid
02local player
03 
04 
05local function showinfoasset()
06local store = game.Players:FindFirstChild(player.Name).PlayerGui.store
07local image = store.frame.frame.Thumbnail
08local name = store.frame.frame.ItemName
09local price = store.frame.frame.CurrencyAmount
10local price2 = store.frame.frame.CurrencyAmount2
11local disc = store.frame.description
12local asset = game:GetService("MarketplaceService"):GetProductInfo(assetid)
13price.Text = asset.PriceInRobux
14price2.Text = asset.PriceInTickets
15disc.Text = asset.Description
View all 62 lines...
0
There's absolutely no reason for this at all, if the given code is the only code that controls the prompting. Do you have skype? Perhaps I can help you better from there. Goulstem 8144 — 10y

1 answer

Log in to vote
1
Answered by
DrJonJ 110
10 years ago

Your problem with the ServerScript one is that is runs all of them together. Meaning that when player A clicks, it triggers the function for player B. This is bad practice, and the reason it shows everyone the info UI is because you don't tell it what player to show it to.

I will edit this post later with a fix if you still can't figure it out.

Tip: add a parameter for the player object instead of using 'script.Parent' and you'll only need one script in ServerScriptService.

Maybe I should do a blog post on efficiency...

0
thank you. i was just told that MouseClick fires for all players. i didn't know this. i'm working on a fix right now. I thought it was best practice to get the event from the client with one clientside script and then process the event with another serverside script . johnnygadget 50 — 10y
0
While it does fire for all players, you can still use it. Just make sure that you check if the player is the same one returned from the function as your first line. DrJonJ 110 — 10y
Ad

Answer this question