Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to change speed using a gamepass?

Asked by 2 years ago

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!

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. PaleNoobs 37 — 2y

3 answers

Log in to vote
0
Answered by
Antelear 185
2 years ago
Edited 2 years ago

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!

Ad
Log in to vote
0
Answered by
sncky -20
2 years ago
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)
Log in to vote
0
Answered by 2 years ago

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

Answer this question