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 check to see if the player has the given gamepass and give them the item?

passId = 6632153  --gravity
passId2 = 6632270 --speed
market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	function hasGravityPass(player)
		return market:UserOwnsGamePassAsync(player,passId)
	end
	function hasSpeedPass(player)
		return market:UserOwnsGamePassAsync(player,passId2)
	end
	player.CharacterAdded:Connect(function(char)
		if hasGravityPass() == true then
			grav = game.ServerStorage.GravityCoil:Clone()
			grav.Parent = player.Backpack
		end
		if hasSpeedPass() == true then
			speed = game.ServerStorage["Acceleration Coil"]:Clone()
			speed.Parent = player.Backpack
		end
	end)
end)

It is returning with an error of "Argument 1 missing or nil"

1 answer

✓ Accepted answer
passId = 6632153  --gravity
passId2 = 6632270 --speed
market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
    if market:UserOwnsGamePassAsync(player.UserId,passId) then
	game.ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("Backpack")
end
if market:UserOwnsGamePassAsync(player.UserId,passId2) then
	game.ServerStorage["Acceleration Coil"]:Clone().Parent = player:WaitForChild("Backpack")
     end
   end)
end)

this will give them the item when the character has loaded if they have the gamepass

1 comment

0

okay thanks

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