Hi, I'm trying to make a script so when someone with a certain game pass held down shift and walked forward they would sprint. I've made the sprint script and that works perfectly! I just need a script so people who but the game pass only them can sprint.
Cheers
I wanted to the same thing on my 2nd game I ever made. It worked. Take into account that I have no clue wether your run script is in a local script or in a regular script, so I will do something different that should be easier to you:
Getting Started
Go ahead into Workspace
and insert aScript
. Now Move your run script Lighting. Name the script you just made "GamePassRun" and name your run script "RunScript"
In the script we just made we will define a variable. This variable will tell the script what the gamepass id is. Go to the gamepass you made on roblox.com, and on the link at the top of the screen, it should say something like this: roblox.com/gamepass/run-gamepass/id?=123456/
copy the numbers after it says id onto your clipboard. The other variable will define your run script now we will begin the script:
local id = 123456 -- gamepassId local RunScript = game.Lighting.RunScript-- this tells the script what your run script is.
now we will continue the script, I'll explain along the way:
local id = 123456 -- paste the id you copied instead of these numbers local RunScript = game.Lighting.RunScript -- this tells the script what your run script is. game.Players.PlayerAdded:Connect(function(player) -- this adds a function to the player when he/she joins if game:GetService("GamePassService"):PlayerHasPass(player, id) then -- this checks if the player has the gamepass local clone = RunScript:Clone() -- Clones your script clone.Parent = player -- Moves the run script into the player else print(player.Name.. "Does not have pass, Script Failed to make" ..player.Name.." Sprint")--Prints that the player does not have the gamepass needed to be able to sprint. end end)
raw:
local id = 123456 local RunScript = game.Lighting.RunScript game.Players.PlayerAdded:Connect(function(player) if game:GetService("GamePassService"):PlayerHasPass(player, id) then local clone = RunScript:Clone() clone.Parent = player else print(player.Name.. "Does not have pass, Script failed to make " ..player.Name.." sprint") end end)