Need Help With Gamepasses

Hello I am having a minor problem. A little help will be appreciated. The problem is when I buy gamepass in game it works fine and give me speed. But when I die It no longer give me speed. Here is a video of gamepass and Image of my code.

Video :

Image :

Please help me! :sob:

A tip is that you could write plr.UserId instead of game.Players[char.name].UserId.
It’s also safer since you don’t depend on the users name.

try using plr.Character.Humanoid.WalkSpeed instead since it works at the purchase.

1 Like

MarketplaceService:UserOwnsGamePassAsync() caches (temporarily saves) the value from the first call to avoid redundancy. According to this post, the function will return false for 10 seconds before updating. I wouldn’t expect many players to die within 10 seconds of purchasing the game pass, so I’d probably write this off as a minor inconvenience.

Hey!

Everything you need to do is create RemoteEvent and put it into ReplicatedStorage
Screenshot_133

Okay, next create local script and put it into StarterGui
write this into local script

local player = game.Players.LocalPlayer
local character = player.Character

character:WaitForChild("Humanoid").Died:Connect(function()
game.ReplicatedStorage.Death:FireServer()
end)

Next create script and put it into ServerScriptService
write this into script

local mps = game:GetService("MarketplaceService")
local gamepass_id = --gamepass id here

    game.ReplicatedStorage.Death.OnServerEvent:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if mps:UserOwnsGamePassAsync(plr.UserId, gamepass_id) then
		  char:FindFirstChild("Humanoid").WalkSpeed = 300
		end
    end)
end)

Now when character dies speed boost will saves!

Hope this helps

This is going to generate unnecessary network traffic and has the capability to generate false or mishandled results especially since you have no security on that remote. This entire process can be done exclusively on the server. The client should not be involved at any step.

It’d be much better to cache the fact that the player owns the pass anyway. Make your own cache. The initial ownership state should be whatever UserOwnsGamePassAsync returns and then be modified from PromptGamePassPurchaseFinished. Ownership check can be done from here then, not MarketplaceService after every respawn.

1 Like

As far as I can see, it’s because you didn’t make a gamepass, you made a DevProduct. This means, you have to buy it every time again. It’s temporary

To make a gamepass (PERMANENT) go to your game >> Store >> click the + and configure it

Let me know if this solved the problem :smiley:

The prompt no longer reflects whether or not the item is a game pass or developer product. Here is the game pass referenced in the OP.

1 Like