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

Help me with my walkspeed gamepass please?

I've been trying to make a walkspeed gamepass and It seems to not be working, I've made a script but whenever I play my game it won't work, please help?

game.Players.PlayerAdded:connect(function(player)
 player.CharacterAdded:connect(function(character)
  if game.MarketplaceService:PlayerOwnsAsset(player,4653124) then
   character.Humanoid.WalkSpeed = 36
 end
end)
end)

It would be great if you could help me out on this, any recommendations?

3 comments

0

Please check your output, the problem must be from either the Script, or the Lines, since lines seem fine, try to use it in LocalScript, in Starterpack, or Workspace.

0

I think the error's your asset, it doesn't look like an actual item for me. I mean; it is, but it's owned by someone who's not you, and it's offsale. Might want to double-check the ID.

2 answers

✓ Accepted answer

You're using MarketplaceService:PlayerOwnsAsset() with a gamepass id, while that function only accepts the asset id.

Each gamepass has both asset id and gamepass id. Gamepass id is usually shorter than its asset id.

If you want to check if a player owns a gamepass by its gamepass id, you need to use MarketplaceService:UserOwnsGamePassAsync(), like this:

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 4653124) then

But you can also obtain the asset id of your gamepass to be able to use it with PlayerOwnsAsset():

if game:GetService("MarketplaceService"):PlayerOwnsAsset(player.UserId, 1929538711) then --1929538711 is your gamepass's asset id

So, with some corrections, your code should look like this:

local passOwners = {} --add to this table if they buy it in game, so they don't have to rejoin
game.Players.PlayerAdded:Connect(function(plr)
	passOwners[plr.Name] = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 4653124)
	plr.CharacterAdded:Connect(function(char)
		if passOwners[plr.Name] then
			char:WaitForChild("Humanoid").WalkSpeed = 36
		end
	end)
end)

Watch alvinblox, He gets you started with serious stuff

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