game.Players.PlayerAdded:connect(function(player)
while true do
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 7384369) then
if player.Backpack:FindFirstChild("GravityCoil") == nil and player.Character:FindFirstChild("GravityCoil") == nil then
print(player.Name .. " got an item!")
local b = game.Lighting:FindFirstChild("GravityCoil"):Clone()
b.Parent = player.Backpack
end
end
wait(1)
end
end)
✓ ANSWER ACCEPTED
How do I make it so when the player buys the gamepass it checks it and gives them the gear?
2 answers
✓ Accepted answer
local MS = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(plr)
repeat wait() until plr.Character
if MS:UserOwnsGamePassAsync(plr.UserId, 7384369) then
if plr.Backpack:FindFirstChild("GravityCoil") == nil and plr.Character:FindFirstChild("GravityCoil") == nil then
print(plr.Name .. " got an item!")
local b = game.Lighting:FindFirstChild("GravityCoil"):Clone()
b.Parent = plr.Backpack
end
end
end)
~~~~~~~~~~~~~~~~~game.Players.PlayerAdded:connect(function(player)
while true do
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 7384369) then
if player.Backpack:FindFirstChild("GravityCoil") == nil and player.Character:FindFirstChild("GravityCoil") == nil then
print(player.Name .. " got an item!")
local b = game.Lighting:FindFirstChild("GravityCoil"):Clone()
b.Parent = player.Backpack
end
end
wait(1)
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Defining the players UserId is important, so for this to work mainly you need (player.UserId) not player.userid. Also, no need for the while true do loop. It runs upon them joining the game.