Basically, I can't figure out how to "detect" the player's name and have "PlayersNameHere" be the player's name.
game.Workspace.PlayerHolder.PlayersNameHere
I tried this.
local MarketplaceService = Game:GetService("MarketplaceService") MarketPlaceService.ProcessReceipt = function(player) local plrname = player.name local gwpn = game.Workspace.PlayerHolder gwpn.plrname.Humanoid.Walkspeed = 25 return Enum.ProductPurchaseDecision.PurchaseGranted 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
-- find the player based on the PlayerId in receiptInfo local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId) if not player then -- Seems like we can't find the player... already left? return Enum.ProductPurchaseDecision.NotProcessedYet -- Can't process end
The way I would save the name is when the player first joins the game. Have a running table store their data.
local playersData = {} game.Players.PlayerAdded:Connect(function(Player) playersData[Player.UserId] = Player.Name 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
function processReceipt(player)
and add this code to the bottom of your script
MarketPlaceService.ProcessReceipt:connect(processReceipt)