#Sprint with energy

1 messages · Page 1 of 1 (latest)

tulip bluff
#
RunService.Heartbeat:Connect(function(dt)
    if fasttt and humanoid.MoveDirection.Magnitude > 0 then
        if energy.Value > 0 then
            energy.Value = math.max(0, energy.Value - dt * 5)
        else
            
            fasttt = false
            humanoid.WalkSpeed = slow
        end
    end
end)

my energy just doesnt goes sown and i just cant walk faster

#

the full script

----Locals---------------------------------------

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer
local function getHumanoid()
    local character = player.Character or player.CharacterAdded:Wait()
    return character:WaitForChild("Humanoid")
end

-----Energy----------------------------------


local energy = player:WaitForChild("energy")

-------------- Speeds -----------------------
local slow = 8
local speed = 15
local humanoid = getHumanoid()
humanoid.WalkSpeed = slow

local fasttt = false

-------------- Key Pressed -------------------
UserInputService.InputBegan:Connect(function(input, processed)
    if processed then return end
    if input.KeyCode == Enum.KeyCode.LeftShift then
        fasttt = true
        humanoid.WalkSpeed = speed
    end
end)

-------------- Key Released ------------------
UserInputService.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        fasttt = false
        humanoid.WalkSpeed = slow
    end
end)


RunService.Heartbeat:Connect(function(dt)
    if fasttt and humanoid.MoveDirection.Magnitude > 0 then
        if energy.Value > 0 then
            energy.Value = math.max(0, energy.Value - dt * 5)
        else
            
            fasttt = false
            humanoid.WalkSpeed = slow
        end
    end
end)


-------------- Respawn Handling --------------

player.CharacterAdded:Connect(function(char)
    humanoid = char:WaitForChild("Humanoid")
    humanoid.WalkSpeed = slow
end)
mellow pond
#

whats the issue?

#

oh nvm i got it