so I have some guns. Everything works pretty great but when sprinting (or pressing shift), I can’t switch weapons. If I press a number, it just kinda glitches my camera and my mouse doesnt get locked in the center until I move my mouse back in. The only thing I can do is switch between 3 and 5 while sprinting. I also binded the F key to sprint and everything works fine, but left shift doesn’t. Any ideas on how I can fix this? I know it’s gotta be possible because I’ve played countless shooters that have no issue with this. Im using UserInputService to detect inputs when pressing the number keys and shift.
gif of me pressing 3 to equip a weapon, and then me sprinting and trying to equip another weapon,
mouse loses focus of the window or something.
This is most likely an issue where sprinting (your shift key) is “eating” up your other events. Can you provide code examples? You should also just considering implementing the shift key the same as you’ve implemented the “F” key as you claim using “F” to sprint is fine but using the shift key breaks things.
Shift and the F key are both implemented the same way. The issue is that it seems to lose focus of the window when pressing shift and a number other than 1 or 3. Using input service, F works, left shift doesnt.
if gameProcessed then return end
if io.KeyCode == Enum.KeyCode.LeftShift or io.KeyCode == Enum.KeyCode.F and moveVector.vector.magnitude ~= 0 and not client.Character.Humanoid:FindFirstChild("Slow") then
doMethodSafe('sprint', true)
character:sprint(true)
elseif io.UserInputType == Enum.UserInputType.MouseButton2 then
doMethodSafe('aim', true)
carriedStances.aiming = true --currentGun and currentGun.aiming or true
elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
doMethodSafe('shoot', true)
elseif io.KeyCode == Enum.KeyCode.R then
doMethodSafe('reload', true)
end
end)
The code above looks incorrect (I am possibly wrong), you should try this for the “if statement” at the top:
if (io.KeyCode == Enum.KeyCode.LeftShift or io.KeyCode == Enum.KeyCode.F) and moveVector.vector.magnitude ~= 0 and not client.Character.Humanoid:FindFirstChild("Slow") then
Edit: Actually on second thought I don’t think it would matter, you’re welcome to try anyways though.
Tried it out, didnt change anything tho. same issue of what seems like the window losing focus when pressing shift + a number besides 1 or 3. switching between 1 and 3 work fine but any other slot messes things up