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 6 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?

for i, v in pairs (game.Players:GetPlayers()) do
    if v then
        if game:GetService("MarketplaceService"):PlayerOwnsAsset(v, 880299391)then
            v.Character.Humanoid.WalkSpeed = 25
        end
    end
end

1 answer

Log in to vote
0
Answered by 6 years ago

Try using

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

Answer this question