Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My ROBLOX Script Broke On My Game With $ Stuff While It Works Without Some Parts. Can Someone Help?

Asked by 6 years ago

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

0
To shorten your title, you do NOT need to say "my roblox script broke on my game" because why else would you be here? hiimgoodpack 2009 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

PlayerHasPass needs to be:

if game:GetService("GamePassService"):PlayerHasPass(p, 1446105009) then 
0
If it works please press the accept answer button UltraaaDev 85 — 6y
0
no, GamePassService is deprecated SebbyTheGODKid 198 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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
0
On Line 3 of the PlayerHasPass function, I found something. You spelled PlayerOwnsAsset wrong. xXprohax0r1337Xx 74 — 6y

Answer this question