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

How to get player's name? GetFullName() won't do the thing it should do.

--LocalScript, willing to change to script later because localscript can't handle purchase script
local playerName = game.Players:GetFullName()
		if game.Workspace.playerName:FindFirstChild("Humanoid") ~= nil then
		game:GetService("MarketplaceService"):PromptProductPurchase(player,382137613)
		end
		end)

This is my Developer Product short code(not full code). I only used

....MouseButton1Click:Connect(function(player)
	game:GetService("MarketplaceService"):PromptProductPurchase(player,382137613)
end

and it said player must be type of Player, but type of is nil so i added GetFullName() and FindFirstChild to get the humanoid, but it won't get the humanoid.

2 comments

0

Sorry for the cut code. This is the full code: game:GetService("MarketplaceService"):PromptProductPurchase(player,382137613)

0

Also please tell me the right code to finish purchase. My full code : script.Parent.Coin1000.MouseButton1Click:Connect(function(player) local playerName = game.Players:GetFullName() if game.Workspace.playerName:FindFirstChild("Humanoid") ~= nil then game:GetService("MarketplaceService"):PromptProductPurchase(player,382137613) end end) game:GetService("MarketplaceService").ProcessReceipt

1 answer

✓ Accepted answer

game.Players:GetFullName() will return ”game.Players”. If you're using a LocalScript, you can use player = game.Players.LocalPlayer. With RemoteEvents, they return the player as the first argument.

This is the code for a LocalScript, which won't work for you reasons you said, but it should help you.


local player = game.Players.LocalPlayer
 
	....MouseButton1Click:Connect(function()	 
    game:GetService("MarketplaceService"):PromptProductPurchase(player, 382137613)
end)

I don't remember how to process developer products, but the wiki gives you everything you need, even code you can copy and edit.

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