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

Gamepass script wont execute when criteria is met?

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

✓ Accepted answer

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

1 comment

0

Thanks!

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