Trying to make an FPS game, made a press R to reload script, however, once I reload, every time I shoot, it automatically reloads, even if I've only shot one bullet. Any suggestions on how I can fix it?
userInput.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then if input.UserInputType == Enum.UserInputType.Keyboard or Enum.UserInputType.Gamepad1 then local keycode = input.KeyCode if keycode == Enum.KeyCode.R or Enum.KeyCode.ButtonX then reload_sound:Play() reload_sound.Ended:Wait() gun.Ammo.Value = 12 end end end
end)
the or
condition will only work if you repeat what's on the other side, otherwise your just repeating a statement and anything will be accepted.
this is your fix:
line 04
if keycode == Enum.KeyCode.R or keycode == Enum.KeyCode.ButtonX then
line 02
if input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.Gamepad1 then
If this fixes your problem, consider accepting it as your answer.