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

My Script to Prompt Gamepass Purchases isn't working?

The error is "MarketplaceService:PromptGamePassPurchase() player should be of type Player, but is of type nil"

Here is the code:

local id = 6399322

script.Parent.Touched:Connect(function(hit) local plr = workspace[hit.Parent.Name] local player = game.Players:GetPlayerFromCharacter(plr) game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)-this is the line that isn't working- end)

1 answer

Player should not be workspace[hit.Parent.Name] but instead should be hit.Parent.Name. If this is inside of a function, you should do it like this:

function MyTouchFunction(hit)
local Player = game.Players[Character.Name]
local Character = hit.Parent
local Name = Player.Name
-- Other code.
end

Let me know if this doesn't work.

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