What's wrong with this script?

local mps = game:GetService("MarketplaceService")

local id = 19083281

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(chr)
        local fol = Instance.new("Folder", plr)
        fol.Name = "Player"
        
        local int = Instance.new("IntValue", fol)
        int.Name = "Sprintspeed"
        
        if mps:UserOwnsGamePassAsync(plr.UserId, id) then
            int.Value = 100    
        else
            int.Value = 50
        end
    end)
end)

I have this script to check if a player owns a gamepass, if so change a value to 100 instead of 50. But it always is 50 even when they have the gamepass. What’s wrong with it?

Are you sure you own the gamepass?
Try to make a print to see if you own it or not.

You could also make a quick purchase prompt to buy your gamepass (for free.) and see if it works.

1 Like

Yes, i do own the gamepass

image

Before the if statement place a print to see what is printed for “plr.UserId” and “id” to see if the inputs are correct.

print(plr.UserId)
print(id)

if mps:UserOwnsGamePassAsync(plr.UserId,id) then

Make sure the print statements print out the correct values (your user ID and the ID of the game pass).

1 Like

Yes it’s printing correctly

image

Place a print statement inside of the first if condition to see if it’s actually running or not.

if mps:UserOwnsGamePassAsync(plr.UserId,id) then
     print("Condition for value to be 100 met.")
     int.Value = 100

Oh well, now this is weird
image

I think I see an error at the top of the ss?

That’s something else in the game

ok I was just making sure about that

So the code definitely works, maybe it is working but just wasn’t reflected? Put another print statement under the else condition and see if it is actually setting it to 50 or not. If only the print statement for the if condition fires and not for the else condition, it means it’s working as intended.

Ok so basically two scripts were messing themselves up, locally it was 50 but server sided was 100. I will fix it now. Thanks for all the help

1 Like