I have following Script, which is placed under a ScreenGui in StarterGui. It is supposed to tell a player to buy a T-Shirt forever until they do, unless they are on the ExemptPlayers list.
local AccessShirt = 317838472 --ID of your group's access shirt
local Player = game.Players.LocalPlayer
local ExemptPlayers = {'GShocked','TCAPI'} --Any players you choose to be exempt of payment
local PlayerExempt = false
for i = 1, #ExemptPlayers do
if Player == ExemptPlayers[i] then
PlayerExempt = true
print("Exempt player joined!")
end
end
repeat
game:GetService('MarketplaceService'):PromptPurchase(Player, AccessShirt)
print("Player hasn't bought")
wait(1)
until PlayerExempt == true or game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, AccessShirt) == true
This, however, returns the following error:
MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil
Fixed Code:
local AccessShirt = 317838472 --ID of your group's access shirt
local Player = game.Players.LocalPlayer
local ExemptPlayers = {'GShocked','TCAPI','MushyLesx'} --Any players you choose to be exempt of payment
local PlayerExempt = false
local Purchased = false
for i = 1, #ExemptPlayers do
if Player.Name == ExemptPlayers[i] then
PlayerExempt = true
print("Exempt player joined!")
end
end
script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(Player, AccessShirt)
end)
while Purchased == false do
if PlayerExempt == true or game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, AccessShirt) == true then
script.Parent.Parent:Destroy() --Destroy the ScreenGui blocking you from entering
Purchased = true
else
print("Player canceled purchase.")
end
end

1 comment
Thanks, I already fixed my problems but you perfectly outlined them.