Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help needed with gamepass script. Could someone help, correct and explain?

Hello. I am trying to figure out how gamepasses work but I am a little stuck.

I want to make a few battlepasses, one that makes you jump a little higher and one to make you faster. I found a tutorial online but since Roblox has been updated once, the script doesn't work anymore. Could someone give me an example script and explain why it's written like that?

Please, keep in mind I am pretty much a beginner, and just trying to create a game that's most about parkour. (aka obby, I believe.) I want to have more experience and I think this is the next step for me.

This was the script the guy gave me(and others of course.) on youtube.

game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if game.MarketplaceService:PlayerOwnsAsset(player,1160701187) then character.Humanoid.WalkSpeed = 50 end end) end)

Thank you, oSevenSo

1 answer

✓ Accepted answer

To start off with

game.MarketplaceService:PlayerOwnsAsset

checks to see if a player owns a specific asset rather than a game pass. And to add on, you are right, there has been a change in checking whether or not a player owns a game pass, but the change is minor.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
	    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 1160701187) then
    	    character:WaitForChild("Humanoid").WalkSpeed = 50
	    end
    end)
end)

This should function correctly

Explanation:

game:GetService("MarketplaceService"):UserOwnsGamePassAsync(userID, gamePassID)

Returns either true or false. the userID represents the player's userID number, and the gamePassID represents the ID number of the game pass. This async checks whether or not the player has the pass or not.

I hope this helps! LMK if any problems come up :)

This discussion is preserved as it was. New answers, comments, and votes are closed.