I have a speed coil gamepass, when the player joins the game, we check if they have the speed coil gamepass. If they do, then we give them the speed coil.
So what's happening right now is, that whenever they join the game, they get the speed coil. But before giving them, I want to check if they already have it in their backpack. In simpler words, let's suppose the player joins the game. They own the game pass and get their speed coil. Now they leave the game and join again. They get the speed coil again. Now in this way, they can easily spam their backpack.
So this is what I tried (normal script):
local SpeedCoilId = GamePassIdHere
game.Players.PlayerAdded:Connect(function(player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, SpeedCoilId) then
if not player.Backpack:FindFirstChild("SpeedCoil") then
local clonedSpeedCoil = game.ReplicatedStorage.Tools.SpeedCoil:Clone()
clonedSpeedCoil.Parent = player.Backpack
clonedSpeedCoil.Parent = player.StarterGear
end
end
end)
I usually use this type of check whenever I give the ability to players to get items. And not just keep clicking that item to spam their inventory. I did something similar here but with no success. The player still keep getting their speed coil everytime they join.
How can I stop this? Is it because the script runs before their backpack has been loaded? Any way to fix this?
Thanks for any help
