So in my game I made a spriting system, easy right? In the game we have a hotbar as well where you can click 1, 2, 3 to equip weapons. Well while testing everything out I came across this really weird bug where I hold (W + Shift) and then while holding I click the key “2” Everything breaks. My player stops moving and inputs stop working for W A S D and then they start working after like 5 seconds. I tried literally everything to fix it and nothing worked. Heres the code I have for my sprinting system and it’s not really anything crazy which is why I am so confused why this is happening:
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local MaxSpeed = false
local Sprinting = false
local CurrentSprint = Player:WaitForChild("Current")
local MaxSprint = Player:WaitForChild("Max")
local Depleted = Player:WaitForChild("Depleted")
local TS = game:GetService("TweenService")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local FovInfoOut = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local FovInfoIn = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
local TimeSinceSprint = 0
UIS.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.LeftShift and CurrentSprint.Value > 0 and Sprinting == false then
Sprinting = true
MaxSpeed = false
local TweenFov = TS:Create(workspace.CurrentCamera, FovInfoOut, {FieldOfView = 80})
TweenFov:Play()
local SpeedTween = TS:Create(Humanoid, TweenInfo.new(1), {WalkSpeed = 30})
SpeedTween:Play()
SpeedTween.Completed:Connect(function()
MaxSpeed = true
end)
end
end)
UIS.InputEnded:Connect(function(input, gp)
if input.KeyCode == Enum.KeyCode.LeftShift then
if Sprinting then
local TweenFov = TS:Create(workspace.CurrentCamera, FovInfoIn, {FieldOfView = 70})
TweenFov:Play()
Sprinting = false
end
end
end)
Obviously my actual code for the sprinting is below but I don’t want to bore with code everywhere. But the weird thing is that is if I do the combination (W + Shift + 2) and warn in InputEnded, IT FIRES. And Im like 99% sure this is a roblox bug where if ends all input for some reason when you press 2 with that combination, and literally any other Keyboard button doesn’t do it; If I press 1, 3, 4 … etc it doesn’t do it, but as soon as I click 2 while sprinting it stops and fires something called:
Enum.KeyCode.Unknown
So I tried to work around this and still nothing. The crazy part is I opened up a new baseplate because I though you know that it may have been another script that was messing it up and I put in the regular sprinting code and BOOM it still did it (Only with the Key 2). This bug is very critical because players in my game are going to continously switch weapons while sprinting and I don’t want them to leave because of this bug. Sorry to bore with so much, but I feel like this had to be explained throughouly because no one has ever posted something on this and I am confused if this is just me or not. But if anyone has any solutions or workarounds for this please help, thanks!