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

How would i make a gamepass that if someone owns it will change a value?

Asked by 5 years ago
Edited 5 years ago

this is what i have so far and it doesnt work

local id = 5546149

game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        player.leaderstats1.xpmulti.Value = 0   
        print(player.Name .. " has the game pass!") 
    else
        player.leaderstats1.xpmulti.Value = 2
        print(player.Name .. " doesn't have the game pass...")
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago

GamePassService only works for old game passes. It is now replaced with MarketplaceService:UserOwnsGamePassAsync() and MarketplaceService:PromptGamePassPurchase() For more information, see this article.

As for your code, this is how it should end up.

local id = 5546149

game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then 
        player.leaderstats1.xpmulti.Value = 0   
        print(player.Name .. " has the game pass!") 
    else
        player.leaderstats1.xpmulti.Value = 2
        print(player.Name .. " doesn't have the game pass...")
    end
end)
0
the script still doesnt change the value of the leaderstat xxethanb1xx 14 — 5y
0
Does it error? Just reading back over the code, I see it says ``leaderstats1.xpmulti``, which might be a typo on your part. protectiveebob 221 — 5y
0
i put leaderstats1 just so it would not appear on the screen xxethanb1xx 14 — 5y
0
Oh okay, got you. Does anything print? protectiveebob 221 — 5y
View all comments (7 more)
0
the only thing it prints is that i own the gamepass xxethanb1xx 14 — 5y
0
Hmm, how do you know that it's not changing the value? Number value objects have a default value of 0, and you're setting their value to 0 if the player owns the pass... protectiveebob 221 — 5y
0
oh yeah i swapped them around and nothing changed xxethanb1xx 14 — 5y
0
Idk man, it's probably something really simple that I'm overlooking. protectiveebob 221 — 5y
1
well thanks for trying xxethanb1xx 14 — 5y
1
i found out how to make it work i had to add the value in the script xxethanb1xx 14 — 5y
0
Oh XD of course protectiveebob 221 — 5y
Ad

Answer this question