local Frame = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid
if char then
humanoid = char:FindFirstChildWhichIsA("Humanoid")
else
char = plr.CharacterAdded:Wait()
humanoid = char:FindFirstChildWhichIsA("Humanoid")
end
local speeds = Frame:WaitForChild("Speeds")
local event = Frame:WaitForChild("Speed")
local enabled = Frame:WaitForChild("Enabled")
local tired = false
local running = false
local moving = false
--------------------
--Config
local stamina = 250
local walk = speeds.Walk
local run = speeds.Run
local exhaust = speeds.Exhaust
--------------------
local function ChangeSpeed(spd)
local char = plr.Character
local humanoid
if char then
humanoid = char:FindFirstChildWhichIsA("Humanoid")
end
if humanoid.WalkSpeed ~= spd then -- Preventing remote spam.
event:FireServer(1055299,spd)
end
end
game:GetService("UserInputService").InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift and char:FindFirstChild("IsRunning").Value == true then
if key.KeyCode == Enum.KeyCode.F then
running = true
end
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
if key.KeyCode == Enum.KeyCode.LeftShift then
char:FindFirstChild("IsRunning").Value = false
running = false
end
end
end)
while wait() do
if enabled.Value == true then
if humanoid then
if humanoid.MoveDirection == Vector3.new(0,0,0) then moving = false else moving = true end
if tired then
ChangeSpeed(exhaust.Value) -- Rest
Frame.Rest1.Visible = true
Frame.Rest2.Visible = true
if not moving then
stamina = stamina + 1
end
if stamina > 0 then
tired = false
Frame.Rest1.Visible = false
Frame.Rest2.Visible = false
Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,25), "Out", "Quad", 0.1, true)
end
elseif running == true then
if moving then
ChangeSpeed(run.Value) -- Sprint
stamina = stamina - 1
Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,25), "Out", "Quad", 0.1, true)
if stamina == 0 then tired = true stamina = -10 end
elseif stamina < 250 then
stamina = stamina + 1
Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,25), "Out", "Quad", 0.1, true)
end
else ChangeSpeed(walk.Value) -- Walk
if not moving and stamina < 250 then
stamina = stamina + 1
Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,25), "Out", "Quad", 0.1, true)
end
end
end
end
end
i get no errors but my walkspeed doesnt change even tho the bool value is set to true
local function ChangeSpeed(spd)
local char = plr.Character
local humanoid
if char then
humanoid = char:FindFirstChildWhichIsA("Humanoid")
end
if humanoid.WalkSpeed ~= spd then -- Preventing remote spam.
event:FireServer(1055299,spd)
end
end
got rid of the bool value yet nothing changed, im thinking of using a script like this
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local anim1 = hum:LoadAnimation(script:WaitForChild("BlockAnim"))
local blockingval = char:WaitForChild("Sprint")
anim1:Play()
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and char.IsRunning.Value == true then
anim1:Play()
hum.WalkSpeed = 34
script.Run1:Play()
script.Run2:Play()
end
end)
game:GetService("UserInputService").InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
char.isRunning.Value = false
anim1:Stop()
hum.WalkSpeed = 8
wait(5)
hum.WalkSpeed = 16
end
end)
Okay so I tested your code, and your problem is that isRunning isn’t being turned on. Another problem might be is that somewhere in your full code, it might be a typo.