Help! My Script Is Broken! It Won't Do Anything To The Money. Can Someone Fix It? It Worked Without The (If PlayerHasPass (code) then) Part But I need that part. Thanks!
game.Players.PlayerAdded:connect(function(p) local stats = Instance.new("IntValue", p) stats.Name = "leaderstats" local money = Instance.new("IntValue", stats) money.Name = "Experience" money.Value = 50000 while true do wait(1) money.Value = money.Value + 1 if PlayerHasPass (1446105009) then wait (1) money.Value = money.Value + 9 end end end)
Gamepass Code: 1446105009
PlayerHasPass needs to be:
if game:GetService("GamePassService"):PlayerHasPass(p, 1446105009) then
Add this to the beginning of your code:
local PlayerHasPass = function(player, pass) if pcall(game.isA, player, "Player") then return game.MarketplaceService:PayerOwnsAsset(player, pass) else error("Get no player for argument 1") end end
Now, we can call it like:
if PlayerHasPass(p, 1446105009) then print(p, "has gamepass", 1446105009, "!") end