I have a made a shift to run game pass but cant figure out how to connect the shift to run and the game pass. The game pass and the shift to run are scripted but I can’t figure out how to connect them.
When shift is pressed, check if the player has the shift to run gamepass. If the player doesn’t have it and needs the gamepass, fire the gamepass script with a remote event.
How do I do that? Sorry, I’m kinda new.
Is the shift to run in a LocalScript in the player/character? If so, maybe disable it and enable it from the Gamepass script.
The script only works in a local script in StarterGui.
You could use UserInputService’s InputBegan/InputEnded
Events to detect when a specific key is pressed (Preferably the Shift key in this instance), check if the Player has the Gamepass then either keep or increase its speed
Here’s a rough example in a LocalScript
:
local Player = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")
local UIS = game:GetService("UserInputService")
local Character = Player.Character or Player.CharacterAdded:Wait()
local GamepassID = 000 --Gamepass ID here
UIS.InputBegan:Connect(function(Input, Chatted)
if Chatted then
return
end
if Input.KeyCode == Enum.KeyCode.LShift and MPS:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
Character.Humanoid.WalkSpeed = 30
else
Character.Humanoid.WalkSpeed = 16
end
end)
I believe that will work aswell, put this in a LocalScript inside of it maybe
local Player = game.Players.LocalPlayer
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 1234) then -- Replace 1234 with the gamepass ID
script.Parent.Enabled = true
Why did you remove your script?
Just implement a sanity check using MarketplaceService’s UserOwnsGamePassAsync
function, where the Player’s UserID is the first argument & the Gamepass ID you want to detect is the second (Might’ve mixed them up), then change their walkspeed
if MarketplaceService:UserOwnsGamepassAsync(Player.UserId, GamepassID) then
Character.Humanoid.WalkSpeed = 30
else
Character.Humanoid.WalkSpeed = 16
end
(I didn’t see that you already scripted the Shift to Script & Gamepass)
This is a bit inefficient/redundant, and way less elegant than @JackscarIitt’s solution, but it’ll work.
If I already have the game pass script, where would I put that inside it? Also, the other script makes more sense so could you repost it? lol
Put it inside of the place where the script checks for a shift key press.
You could just put it inside the LocalScript
when you insert your sanity checks if the Player has hit the Shift Key
Would I just put this in workspace?
Nah, put it inside where you had the other LocalScript
The Player would only be replicated across the client side, if you were to put it on the server then it wouldn’t be possible to detect the “Player”
Ok so, all I have so far is what you just gave me. Now I’m stuck on where to put it to make it work and if I need to add anything. (its in a localscript)
What’s your current script so far?
I got confused so I deleted what I had. Now all I have is what you gave me
local Player = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")
local UIS = game:GetService("UserInputService")
local Character = Player.Character or Player.CharacterAdded:Wait()
local GamepassID = 000 --Gamepass ID here
UIS.InputBegan:Connect(function(Input, Chatted)
if Chatted then
return
end
if Input.KeyCode == Enum.KeyCode.LeftShift and MPS:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
Character.Humanoid.WalkSpeed = 30
else
Character.Humanoid.WalkSpeed = 16
end
end)
UIS.InputEnded:Connect(function(Input, Chatted)
if Chatted then
return
end
if Input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16
end
end)
This?
Yea that is all I have got so far.