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!
Differences between local and server scripts
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