So I’m working on a shift to sprint function, nothing too crazy, but something kinda weird is happening. My :InputBegan() function is working as intended, but the :InputEnded() function isn’t, despite using the same conditional statement to confirm that either the LeftShift or RightShift button is being held down (or in this case, being let up). The initial line is running, as shown when adding a print() statement after it, but the code stops working when it gets to line 9. No clue why this isn’t working as it’s practically identical to the :InputBegan() function, just in reverse. Thanks for the help in advance!
local input = game:GetService("UserInputService")
local players = game:GetService("Players")
local localplayer = players.LocalPlayer
local moving = false
input.InputEnded:Connect(function(key, __gameProcessed)
if not __gameProcessed then
if key == Enum.KeyCode.LeftShift or key == Enum.KeyCode.RightShift then
print("Player has stopped.")
localplayer.Character:WaitForChild("Humanoid").WalkSpeed = 20
moving = false
end
end
end)