Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help me with my walkspeed gamepass please?

Asked by 6 years ago

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?

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. AIphanium 124 — 6y
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. Astralyst 389 — 6y

2 answers

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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)
Ad
Log in to vote
0
Answered by 5 years ago

Watch alvinblox, He gets you started with serious stuff

Answer this question