Basically, I can't figure out how to "detect" the player's name and have "PlayersNameHere" be the player's name.
1 | game.Workspace.PlayerHolder.PlayersNameHere |
I tried this.
1 | local MarketplaceService = Game:GetService( "MarketplaceService" ) |
2 |
3 | MarketPlaceService.ProcessReceipt = function (player) |
4 | local plrname = player.name |
5 | local gwpn = game.Workspace.PlayerHolder |
6 | gwpn.plrname.Humanoid.Walkspeed = 25 |
7 | return Enum.ProductPurchaseDecision.PurchaseGranted |
8 | end |
(not a localscript) (a serverside script)
I would recommend reading Roblox Wiki - Leaderboards(Exploiting section) It'll give you some information to secure your purchases among other things.
I also took a gander here Roblox Wiki - MarketplaceService
1 | -- find the player based on the PlayerId in receiptInfo |
2 | local player = game:GetService( "Players" ):GetPlayerByUserId(receiptInfo.PlayerId) |
3 | if not player then -- Seems like we can't find the player... already left? |
4 | return Enum.ProductPurchaseDecision.NotProcessedYet -- Can't process |
5 | end |
The way I would save the name is when the player first joins the game. Have a running table store their data.
1 | local playersData = { } |
2 |
3 | game.Players.PlayerAdded:Connect( function (Player) |
4 | playersData [ Player.UserId ] = Player.Name |
5 | end ) |
You can use obj["string"] to find a child of obj called string, it's the same as doing obj.string
So, you would put game.Workspace.PlayerHolder[plrname] to do what you're trying to do.
Also, I don't believe your 3rd line would work, since ProcessReceipt is an event, you have to connect the event to a function for it to work. Change line 3 to
1 | function processReceipt(player) |
and add this code to the bottom of your script
1 | MarketPlaceService.ProcessReceipt:connect(processReceipt) |