Tool granting gamepass works for some but not all

I have a pass that gives a spawner tool to those who have it. However, some people (who I can confirm have bought it) do not have it in their inventories, but it works fine for others. What’s wrong?

local gamepass_id = 6928932 --enter the gamepass asset id here
local plrs = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)
		if mps:UserOwnsGamePassAsync(player.UserId , gamepass_id) then
			game.ServerStorage.Pizzaspawner:Clone().Parent = player.Backpack
			game.ServerStorage.Pizzaspawner:Clone().Parent = player.StarterGear
		end
end)```
1 Like

Change player.Backpack and player.StarterGear to

player:WaitForChild(“Backpack”)
player:WaitForChild(“StarterGear”)

2 Likes

Thank you! Why does the original script not grant it to some pass owners?

I think the issue is that the script is running before the player is loaded into the game. So for the people with faster wifi speeds it probably works majority of the time but for people with slower internet speeds it the script loads in before they do. By adding a waitforchild, it forces the script to wait for the player to load in and then runs the function. You should use waitforchild more often especially for scripts that run at the start of games.

1 Like

I see, thanks! And now that you mention it, one of the people who had it working has a super expensive laptop

2 Likes