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

Sprinting in a gamepass? I have sprinting how to put it in a gamepass?

Asked by 6 years ago

I have made it so when you press sprint you run, but I can't figure out how to put it into a game pass so they must own it to be able to sprint. https://gyazo.com/61e8f5371ff50f0c5d14cac3822c1d2a

That is my sprint script if someone could help me out that would be great! Thanks in advance!

0
Check the wiki for GamepassService:PlayerHasPass RubenKan 3615 — 6y
0
I checked and couldn't find anything... defender868 -12 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Just add a bool value in them called "CanSprint" or something then create a script not local and add this

local ID = 103728213 --the id to the gamepass

game.Players.PlayerAdded:connect(function(plr)
    local CanSprint = plr:FindFirstChild("CanSprint")
    if CanSprint != nil then
        if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
           CanSprint.Value = true
        end
    end
end)

and if they don't just add this

local ID = 103728213 --the id to the gamepass

game.Players.PlayerAdded:connect(function(plr)
    local CanSprint = plr:FindFirstChild("CanSprint")
    if CanSprint != nil then
        if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
           CanSprint.Value = true
    else
        CanSprint.Value = true
        end
    end
end)

and in your sprint script just add before the KeyDown function

 local CanSprint = plr:FindFirstChild("CanSprint")

and then after it add

if CanSprint  != nil then --Checks if it was found
    if CanSprint.Value == true then
        --code
    end
end

And thats it!

Edit: I would suggest using UserInputService to check for keydown its better because Mouse.KeyDown is depricated!

To use UserInputService for your thing you just do this

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.LeftShift then
        --sprint code
    end
end)

UserInputService.InputEnded:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.LeftShift then
        --sprint code
    end
end)
0
How would I add the keydown for my sprint script? defender868 -12 — 6y
0
I'm not very good at coding could you walk me through it please? defender868 -12 — 6y
0
head's up, it's ~= in lua, not != RubenKan 3615 — 6y
0
Yeah i know i'm use to C# KinqAustinn 293 — 6y
Ad

Answer this question