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

How to change speed using a gamepass?

Hello, I want to make a part that can change speeds, but I only want it to actually change the speed if a user owns a specific game pass. Im kinda new so any help is appreciated thanks!

1 comment

0

Unfortunately, this website is not a request website, only a helping website, similar to the DevForum. You should add your own script that you attempted before asking any questions here. You can use YouTube tutorials too, there are many Gamepass tutorials.

3 answers

Sources

MarketplaceplaceService

StarterCharacterScripts

WaitForChild

Functions

Differences between local and server scripts

Script (LOCAL SCRIPT)

local MS = game:GetService("MarketplaceService")
local GamepassID = 1234 -- whatever the gamepass' id is.

local Char = script.Parent -- when referencing the character we only need to use script.Parent, as the script only runs as soon as it's parented into the character.
local Hum = Char:WaitForChild("Humanoid") -- we need this to change speed.
local User = game:GetService("Players"):GetPlayerFromCharacter(Char) -- this is needed as we need their UserId for MarketplaceService.

if MS:UserOwnsGamePassAsync(User.UserId, GamepassID) then
	Hum.WalkSpeed = 25 --whatever the walkspeed will be.
end

If this has helped you, please mark this answer as the one that helped you!

local id = 111 -- Your Gamepass Id Here
local m = game:GetService('MarketplaceService')
	 
	game.Players.ChildAdded:Connect(function(player)
	     player.CharacterAdded:Connect(function(char)
	          if m:UserOwnsGamePassAsync(player.UserId, id) then
               local h = char:WaitForChild('Humanoid')
	               h.WalkSpeed = 32
	        end
	  end)
end)

Put that script on StarterGui

local ID = 123 --Put your Gamepass ID
local Marketplaceservice = game:GetService("MarketplaceService")
local Player = script.Parent.Parent
local Humanoid = Player.Character.Humanoid

while wait() do
	if Marketplaceservice:UserOwnsGamePassAsync(Player.UserID, ID) then
		Humanoid.WalkSpeed = 32 --Default is 16
	end
end

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