local gamepass = game:GetService("GamePassService")
local market = game:GetService("MarketplaceService")
local part = script.Parent
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
market:PromptGamePassPurchase(game.Players, 4367427794)
part.BrickColor = BrickColor.new("Lime green")
end
end)
Console Error
MarketplaceService:PromptGamePassPurchase() player should be of type Player, but is of type Players
You’re putting the Players service, instead of a single player:
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
market:PromptGamePassPurchase(player, 4367427794)
part.BrickColor = BrickColor.new("Lime green")
end
end)
Both ways definitely work! I just don’t really like creating variables when they’ll only be used once. To me, it’s wasted memory, even if it is just a few bytes.
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
market:PromptGamePassPurchase(player, 1057151)
part.BrickColor = BrickColor.new("Lime green")
end
end)