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

How do I make it so when the player buys the gamepass it checks it and gives them the gear?

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)

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)

1 comment

0

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.

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