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

Sprint on shift bug?

Asked by
PredNova 130
9 years ago

I've found a script from free models and I've been trying to edit it so that when the player is sprinting it takes some hunger and thirst (These are represented on a GUI), But it doesn't work. When you press sprint it continuously sprints and does not stop. There's no outputs either.

local mouse = game.Players.LocalPlayer:GetMouse()
local running = false

function getTool()  
    for _, kid in ipairs(script.Parent:GetChildren()) do
        if kid.className == "Tool" then return kid end
    end
    return nil
end


mouse.KeyDown:connect(function (key) -- Run function
    key = string.lower(key)
    if string.byte(key) == 48 then
        running = true
        local keyConnection = mouse.KeyUp:connect(function (key)
            if string.byte(key) == 48 then
                running = false
            end
        end)
        for i = 1,5 do
            game.Workspace.CurrentCamera.FieldOfView = (70+(i*2))
            wait()
        end
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 24 
            while true do wait() -- I think the problem is here and below. 
            game.Players.LocalPlayer.Thirst.Value = game.Players.LocalPlayer.Thirst.Value - math.random(2,7)
            game.Players.LocalPlayer.Hunger.Value = game.Players.LocalPlayer.Hunger.Value - math.random(1,7)

        end
        repeat wait () until running == false
        keyConnection:disconnect()
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
        for i = 1,5 do
            game.Workspace.CurrentCamera.FieldOfView = (80-(i*2))
            wait()
        end
    end
end)

Thanks :)

0
Do you have an idea where the problem is, that would help parkderp1 105 — 9y

1 answer

Log in to vote
-2
Answered by 9 years ago

The problem, is that you are using a free mod.

0
This scripted worked completely fine until I added the lines that remove thirst and hunger - I also think you'll find this is the script that ends up in your game when you get the Shift On Sprint plugin (That has over 30k downloads). PredNova 130 — 9y
Ad

Answer this question