Speed Gamepass not working

Hello! I have been having problems with my speed gamepass code. I don’t know if there is an error and I was hoping someone could help me.
This is the code:

local Gamepass = 16671522
local Market = game:GetService('MarketplaceService')

game.Players.ChildAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if Market:UserOwnsGamePassAsync(player.UserId,Gamepass)then
			local h = char:WaitForChild('Humanoid')
			h.WalkSpeed = 75
		end
	end)
end)

There’s no error, but you didn’t even define the ID of what gamepass you’re exactly for (Or you’re basically searching for an unknown global variable that the script will not be able to find)

1 Like

I meant this code I forgot to add the first line of code
local Gamepass = 16671522
local Market = game:GetService(‘MarketplaceService’)

game.Players.ChildAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
if Market:UserOwnsGamePassAsync(player.UserId,Gamepass)then
local h = char:WaitForChild(‘Humanoid’)
h.WalkSpeed = 75
end
end)
end)

The script should be in ServerScriptService, correct?

Why not use a PlayerAdded event instead…?

local Gamepass = 16671522
local Market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local h = char:WaitForChild("Humanoid")
        if Market:UserOwnsGamePassAsync(player.UserId,Gamepass)then
            h.WalkSpeed = 75
        end
    end)
end)

Try this?

local Gamepass = 16671522
local Market = game:GetService('MarketplaceService')

game:GetService("Players").PlayerAdded:Connect(function(player)
	if Market:UserOwnsGamePassAsync(player.UserId,Gamepass)then
		local function setSpeed(char)
			local h = char:WaitForChild('Humanoid')
			h.WalkSpeed = 75
		end
		setSpeed(player.Character or player.CharacterAdded:Wait())
		player.CharacterAdded:Connect(setSpeed)
	end
end)

Not sure why you were using ChildAdded instead of player added, also it’s better to create the event if they own it to prevent unnecessary events. Also, there may be a chance the character loaded before the event was created so this would account for it

Tried it and it still didn’t work

Ok let me try this one and i’ll tell you if it works or not

Tried it and it didn’t work sorry

Where is this script located firstly?

I did it in the workspace should I put it in server script service?

Assuming the script is a Script. If not then change it.

local Gamepass = 16671522
local Market = game:GetService('MarketplaceService')

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if Market:UserOwnsGamePassAsync(player.UserId,Gamepass)then
			local h = char:FindFirstChild('Humanoid') or Char:WaitForChild("Humanoid")
			h.WalkSpeed = 75
		end
	end)
end)

Note: if the player doesn’t own the gamepass then it obviously won’t work.

Put it in ServerScriptService and change it to this so we can see what’s going on

local Gamepass = 16671522
local Market = game:GetService('MarketplaceService')

game:GetService("Players").PlayerAdded:Connect(function(player)
	print("A player joins")
	if Market:UserOwnsGamePassAsync(player.UserId,Gamepass)then
		print("User owns gamepass")
		local function setSpeed(char)
			local h = char:WaitForChild('Humanoid')
			h.WalkSpeed = 75
		end
		setSpeed(player.Character or player.CharacterAdded:Wait())
		player.CharacterAdded:Connect(setSpeed)
	end
end)

Did you put the right id firstly and do you own the gamepass and are you testing in studio or ingame?

1 Like

some tips for help
Make it game.Players.PlayerAdded

Make the script in server script service

DONT make it local script

make sure the amepass id is correct

u can remove the CharacterAdded function just do player.Character:WaitForChild(“Humanoid”).WalkSpeed = 75

Testing it in game, I triple checked the id and its correct, and I own the gamepass.

Are you remembering to publish? Stupid question but it could be related. And if you did publish, what does it print?

I think i know the error, some GamePass services doesnt require player id…

Try the parameter (player, Gamepass)

Enable API Service if u havent

I did publish the game and I’m just testing it rn

That’s basically doing the same thing.

Good sir:

In this instance, UserOwnsGamePassAsync does require a User ID

1 Like