Gamepass script not working

Hello. I made a small paycheck system. I also added a “Double Money” Gampass which grants the owner x2 the amount.

Script:

local GettingMoney = false
local MarketPS = game.MarketplaceService

game.Players.PlayerAdded:Connect(function(Player)
while wait(0.1) do
if game.Lighting.ClockTime >= 6.3 and game.Lighting.ClockTime < 6.4 then
if GettingMoney == false then
GettingMoney = true
if MarketPS:PlayerOwnsAsset(Player,14247646) then
Player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 20
game.ReplicatedStorage.NotificationEvents.PayCheck2:FireClient(Player)
else
Player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 10
game.ReplicatedStorage.NotificationEvents.PayCheck:FireClient(Player)
wait(25)
GettingMoney = false
end
end
end
end
end)

Problem:
The script runs fine and adds the value but the problem is when the person WITH the gamepass joins then the script still goes to the lines under “else” instead of following the line above “else”

Sorry if there is an obv mistake, I am not a great scripter. I am still learning.

Try with UserOwnsGamePassAsync(Player.UserId, GamePassId)

UserOwnsGamePassAsync

1 Like

Thank :slight_smile: it’s working just fine now!