When a player joins the game, I check if the player has a gamepass and if so then a tool is inserted into the player’s backpack. However, it only works about half of the time. I tried having the game wait for the tool and backpack of the player but there was no change in the results.
My code looks like this:
local mps = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(plr) -- function calls when player joins the game
if mps:UserOwnsGamePassAsync(plr.UserId, 775929758) then --checks if user have gamepass
local gloop = game.ReplicatedStorage.GloopGun:Clone() --clones from repstorage (where the original gloopgun is kept)
gloop.Parent = plr.Backpack --puts it into the players inventory
end
end)
The code is in serverscriptservice and it is a regular script.
Please give me any suggestions as to what I should do to make this more consistent