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

Making a roblox developer products script?

Asked by
crywink 419 Moderation Voter
8 years ago

I've made this script for somebody and I do not know if it will work or not. can somebody please tell me if it will work and if it wont, How to fix it? Thanks.

01local id = script.Parent.ProductID
02 
03function onClicked (mouse)
04    local Humanoid = mouse.Parent:FindFirstChild("Humanoid")
05    if (Humanoid ~= nil) then
06        local Player = game.Players:GetPlayerFromCharacter(mouse.Parent)
07        game:GetService("MarketplaceService"):PromptProductPurchase(Player, id.Value)
08    end
09end
10script.Parent.ClickDetector.MouseClick:connect (onClicked)

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

The MouseClick event in ClickDetector already returns the player. So, you can just define the player from the playerWhoClicked argument.

Here. Let me fix the script for you!

1local id = script.Parent.ProductID
2 
3function onClicked (PlayerWhoClicked)
4    if PlayerWhoClicked then -- Check if player is here! :)
5        game:GetService("MarketplaceService"):PromptProductPurchase(PlayerWhoClicked, id.Value)
6    end
7end
8script.Parent.ClickDetector.MouseClick:connect (onClicked)

Any questions? Leave them in the comments. Thanks!

0
I believe that there are 2 scripts for it, What should the other one say? crywink 419 — 8y
0
this is the first script. where is your OTHER script that handles the purchase? starlebVerse 685 — 8y
Ad

Answer this question