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

How do I make the player run faster if they have a pass?

Asked by
iHavoc101 127
5 years ago
Edited 5 years ago

The parent is a script called"SprintScript Importer":

01function onPlayerEntered(player)
02    repeat wait () until player.Character ~= nil
03    local s = script.SprintScript:clone()
04    s.Parent = player.Character
05    s.Disabled = false
06    player.CharacterAdded:connect(function (char)
07        local s = script.SprintScript:clone()
08        s.Parent = char
09        s.Disabled = false     
10    end)
11end
12 
13game.Players.PlayerAdded:connect(onPlayerEntered)

The child is a local script call "SprintScript":

01local mouse = game.Players.LocalPlayer:GetMouse()
02local running = false
03 
04function getTool() 
05    for _, kid in ipairs(script.Parent:GetChildren()) do
06        if kid.className == "Tool" then return kid end
07    end
08    return nil
09end
10 
11 
12mouse.KeyDown:connect(function (key) -- Run function
13    key = string.lower(key)
14    if string.byte(key) == 48 then
15        running = true
View all 34 lines...
0
Use a code block. pidgey 548 — 5y
0
iHavoc, the next time you ask this question, please highlight all your code then click on the Lua button instead of the >. It makes your code much easier to read so we can help you. beeswithstingerss 41 — 5y
0
ok iHavoc101 127 — 5y

1 answer

Log in to vote
0
Answered by
vkax 85
5 years ago

There's no need to clone a local script, simply just check once the player joins the game.

01local marketplaceService = game:GetService("MarketplaceService")
02local gamepassId = 0 -- your gamepass ID here
03local speed = 25 -- set to whatever walking speed you want
04 
05game.Players.PlayerAdded:Connect(function(player)
06    repeat wait() until player.Character
07    if (marketplaceService:PlayerOwnsAsset(player, gamepassId) then
08        player.Character.Humanoid.WalkSpeed = speed
09        return
10    end
11end)
Ad

Answer this question