Gamepass script failing randomly

I use a script (At bottom of post) to give people with a gamepass gear in my place. When I join, I get the gear, When I used an alt and bought the pass and joined, I got the gear. When I used another alt today, bought the pass, and immediately went into the game, I got the gear. When I join as many servers as possible, I get the gear on each one.
Yet people seem to be randomly complaining about not receiving gear (Cant give more info, this being ROBLOX I just get ‘OGMz u SCAMMER NOOBZ rep0rt3d nuuubb!!!’)

I posted the script to Scripting Helpers, they couldn’t find a problem.

Can anyone shed some light on why this is happening?

local passId = 137238657

function isAuthenticated(player)
return game:GetService(“GamePassService”):PlayerHasPass(player, passId)
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
if isAuthenticated(player)then
tool = game.Lighting.ZombTaser:Clone()
tool.Parent = player.Backpack
end
end)end)

1 Like

People go in-game, then buy the pass from the website and then don’t immediately get the item.

That’s my explanation.

When a user buys a game pass while they’re in-game, because the PlayerHasPass method caches, if they were to rejoin it’d still think they don’t own the game pass.

That’s where the problem comes along, the method shouldn’t cache yet it does. I get people complaining to me with my old game not registering that they have the game pass. I just tell them to try another server and it usually works.

I just use:

local b = get:GetService(“BadgeService”)

if b:UserHasBadge(PlayerId, AssetId) then
end

Does the same thing, works right when they buy the gamepass.

It works it just takes a long time to update. Thus leading to me getting a warning for scamming.

Thanks obama.

So I can just put the gamepass ID in Asset ID? I have never used badges or gamepasses in scripts before last week.

Yeah. You can use any asset.

local passId = 137238657
local players = game:GetService("Players")
local gpServ = game:GetService("GamePassService")
local lighting = game:GetService("Lighting")
local zombTaser = lighting.ZombTaser

players.PlayerAdded:Connect(function(player)
	local backpack = player.Backpack
	player.CharacterAdded:Connect(function(character)
		if gpServ:PlayerHasPass(player, passId) then
			local tool = zombTaser:Clone()
			tool.Parent = backpack
		end
	end)
end)