So I’m using the hook “KeyPress” and what I want it to do is if a player is looking at a vehicle and presses R it opens the menu. I’ve done that but the problem is that after I have pressed R on the car and the menu opens, everytime I look at the car the menu opens without pressing R.
Here’s my current code:
local function CarPress( ply, key ) if not key == IN_RELOAD then return end if ply:GetEyeTrace().Entity:GetClass() == "prop_vehicle_jeep"then net.Start("OpenMrMenuTwenty") net.WriteEntity( ply:GetEyeTrace().Entity ) net.Send(ply) end end hook.Add("KeyPress", "poopoohook", CarPress )
So how do I make it so only when I press R while look at the car it opens and then after it doesn’t unless they press R again