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

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

Asked by 5 years ago
--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.

0
Sorry for the cut code. This is the full code: game:GetService("MarketplaceService"):PromptProductPurchase(player,382137613) ComLBY_Dev 21 — 5y
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 ComLBY_Dev 21 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question