Help with GamePass

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    – I want to give the player more speed if he has the GamePass.

  2. What is the issue? Include screenshots / videos if possible!
    – When the Player reset his character his walk speed becomes normal

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    – I tried to make While loop to solve that but It doesn’t work and I face the same issue.
    (I am new and learning so please help me)
    Here is my code :

local MPS = game:GetService("MarketplaceService")
local GamePassId = 57627339
local Player = game.Players.LocalPlayer
local character = Player.Character
if not character or not character.Parent then
	character = Player.CharacterAdded:Wait()
end

while true do
	wait(1)
	local HasPass = MPS:UserOwnsGamePassAsync(Player.UserId,GamePassId)
	if HasPass == true then
		if character.Humanoid.WalkSpeed ~= 50 then
			character.Humanoid.WalkSpeed = 50
		end
		print(Player.Name.." has the Game Pass")
	else
		print(Player.Name.." does not has the game pass")
		MPS:PromptPurchase(Player,GamePassId)
	end
end
1 Like

remove that (ignore this 00000000

What should I use instead of it?

nothing, just remove it. idk about the walkspeed, looks fine to me but spamming all that code every second isnt good and isnt needed

Here is a code sample that gives the player a walkspeed of 50 if they own the gamepass.

local GamePassId = 57627339

local function CheckGamepass(player)
    local success, boughtGamepass = pcall(function()
		return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId)
	end)

	if success and boughtGamepass then
        if player.Character and player.Character:FindFirstChild("Humanoid") then
            player.Character.Humanoid.WalkSpeed = 50
        else
            player.CharacterAdded:Wait()
            player.Character:WaitForChild("Humanoid")
            player.Character.Humanoid.WalkSpeed = 50
        end
	end
end

game.Players.PlayerAdded:Connect(function(player)
	CheckGamepass(player)
    player.CharacterAdded:Connect(function(character)
        CheckGamepass(game.Players:GetPlayerFromCharacter(character))
    end)
end)
2 Likes

It’s not working. I don’t know why

Try again I edited it. :smiley:

characterlimit