[HELP] How to stop players from "rolling" while aiming a gun

Hi, guys!
I’ve been using this forum for a time and it’s really such a honor to be allowed to use all the great scripts community shares.
I’m here with a question that I can’t manage to answer myself.

I’m looking for a way to stop players “rolling” while aiming a gun (classic press spacebar while aiming). I want to make the shootings more inmersive, and I think that a shooting without people rolling with an AK could make it happen.
I couldn’t find a way to stop it from happen, I’ve been searching in the forum and haven’t found something related to this topic.
I’m not looking for an already developed script (if it exists, of course it would be great to having it), but at least a tip of where could I make it happen.
Thanks in advance for all the usefull info that me and the other developers found in this awesome forum.
Hope you are doing great. Sorry for my english, I speak in Spanish but I do my best.

One way of doing it could be disabling the jump input key that initiates the rolling when aiming with a gun
Try this:

Citizen.CreateThread(function()
  while true do
    if IsPlayerFreeAiming(PlayerId()) then
     DisableControlAction(0, 22, 1) -- 22 is the INPUT_JUMP key
    end
    Citizen.Wait(100)
  end
end)
2 Likes

I think you would want something more like:

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if IsPlayerFreeAiming(PlayerId()) then
     DisableControlAction(0, 22, 1) -- 22 is the INPUT_JUMP key
    else
     Citizen.Wait(100)
    end
  end
end)

DisableControlAction needs to be executed each frame otherwise it won’t disable the control if I recall correctly.

2 Likes

Well you just added Citizen.Wait(0) to the loop, and that doesn’t affect anything

1 Like

Thanks for the fast reply, guys!
It really works. Players are not allowed anymore to “roll” while they’re aiming. There’s a thing I’m starting to look, that is:

If you shoot while left-clicking, the aim dot (crosshair) appears and you can “roll” again. But, it is already difficult to be in a shooting without the “roll” with right click. If I manage to handle the left-click issue, I will put the code here.

Thank you so much guys, you’re awesome !

ok so the script say only when free aiming but I need it also to be while holding the gun it to disable roll because when you jump then aim after that they still roll. how do I do that?

where do you insert this