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

Gamepass script wont execute when criteria is met?

Asked by 7 years ago

I'm trying to make a script so that if a character has a gamepass their walkspeed is increased to 25. No errors are showing up in output, so I don't know what's wrong. The script is a server script found under ServerScriptService. Am I missing something here?

1for i, v in pairs (game.Players:GetPlayers()) do
2    if v then
3        if game:GetService("MarketplaceService"):PlayerOwnsAsset(v, 880299391)then
4            v.Character.Humanoid.WalkSpeed = 25
5        end
6    end
7end

1 answer

Log in to vote
0
Answered by 7 years ago

Try using

1repeat wait() until game.Players.LocalPlayer
2local service = game:GetService("MarketplaceService")
3for i,v in pairs (game.Players:GetChildren()) do
4    if v then
5        if service:PlayerOwnsAsset(v, 880299391) then
6            v.Character.Humanoid.WalkSpeed = 25
7        end
8    end
9end
0
Thanks! noob1126 34 — 7y
Ad

Answer this question