Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Detect a player's name & Place it somewhere in the script? [lol hard to explain]

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)

1 comment

0

Have you tried using connect()?

2 answers

✓ Accepted answer

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)

4 comments

0

What does leaderboards have todo with securing my purchases?

0

I specifically wrote "Exploiting section". But if that doesn't make sense as to how it would secure your purchases then ignore it.

0

And you linked me the "Leaderboards(Exploiting section)" "LEADERBOARDS"

0

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)

1 comment

0

Didin't seem to do anything really.

This discussion is preserved as it was. New answers, comments, and votes are closed.