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

Walkspeed Button that gives walkspeed but i want a gamepass to get more when the player equip it?

This is what the button script does:

local char = script.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local pet = script.Parent
local maxFloat = 0.5
local floatInc = 0.025
local sw = false
local fl = 0
local head = char:FindFirstChild("Head")

hum.WalkSpeed = 16 + 6

I want to add something in the script so that if the player has this gamepass (8350199) then the player gets added +30 walkspeed on top of what it normally gives for people without the gamepass. I tried saying

if 958879047 then
	hum.WalkSpeed = 16 + 6 + 30
end

I know that script is wrong but it is to understand what i am trying to get help to

1 answer

✓ Accepted answer

In order to check if a user owns a gamepass, you need to use UserOwnsGamepassAsync

-- the marketplaceservice needed to check if a user has a gamepass
local marketplaceService = game:GetService("MarketplaceService")

local passId = 958879047 

if(marketplaceservice:UserOwnsGamepassAsync(player.UserId, passId)) then
	-- Give the extra walk speed
end

Note that you need to pass the UserId and not the player instance!

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