local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local tapped = false
local downed = false
local debounce = false
local sprinting = false
local info1 = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0, false, 0)
local anim = script:WaitForChild("Sprint")
local sprintAnim = plr.Character:WaitForChild("Humanoid"):LoadAnimation(anim)
UIS.InputBegan:Connect(function(input, check)
if check == false then
if input.KeyCode == Enum.KeyCode.W then
if tapped == false then
if debounce == false then
tapped = true
wait(0.25)
tapped = false
end
else
if debounce == false then
if plr.Stamina.Value >= 3 then
debounce = true
game.ReplicatedStorage.Events.AdvancedMovement:FireServer("Dash")
local Anim = script["Forward-Dash"]
local DashAnim = plr.Character.Humanoid:LoadAnimation(Anim)
plr.Character.HumanoidRootPart.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 250
DashAnim:Play()
wait(0.3)
debounce = false
end
end
end
elseif input.KeyCode == Enum.KeyCode.LeftControl then
if sprinting == false then
if plr.Character.Humanoid.MoveDirection.Magnitude > 0 then
if plr.Stamina.Value >= 5 then
sprinting = true
plr.Character.Humanoid.WalkSpeed = 25
sprintAnim:Play()
TS:Create(workspace.Camera, info1, {FieldOfView = 80}):Play()
game.ReplicatedStorage.Events.AdvancedMovement:FireServer("SprintStart")
print(sprinting)
end
end
else
sprinting = false
TS:Create(workspace.Camera, info1, {FieldOfView = 70}):Play()
plr.Character.Humanoid.WalkSpeed = 16
sprintAnim:Stop()
print(sprinting)
end
print(sprinting)
end
end
end)
while sprinting == true do
print(plr.Character.Humanoid.MoveDirection.Magnitude)
if plr.Character.Humanoid.MoveDirection.Magnitude > 0 then
if plr.Stamina.Value >= 1 then
game.ReplicatedStorage.Events.AdvancedMovement:FireServer("SprintOn")
else
sprinting = false
TS:Create(workspace.Camera, info1, {FieldOfView = 70}):Play()
plr.Character.Humanoid.WalkSpeed = 16
sprintAnim:Stop()
end
else
sprinting = false
TS:Create(workspace.Camera, info1, {FieldOfView = 70}):Play()
plr.Character.Humanoid.WalkSpeed = 16
sprintAnim:Stop()
end
wait()
end
I've been puzzled as to why the while sprinting == true do loop isn't working. It's not printing anything, and I'm certain that the "sprinting" variable is true due to other methods I've tried. Can I not do this and if so, is there an alternative?
