Why is this running twice? LUA SCRIPTING

Hello, I am having trouble with my script.
Everytime I am at these coordinates in the marker and I click E to toggle the menu it acts as though ive clicked E twice really super fast.


Thanks in advance!
If you need more information just ask me!
To run it you need es_extended.

Here are all of my resources if you think it may be conflicting:

which part of this are you having a problem with? all 3 or just 1?

		--AdminBuildingEntrance
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z) < 1 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to enter the admin building")
			if IsControlJustReleased(0, Keys['E']) then
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingInsideCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingInsideHeading)
				DoScreenFadeIn(5000)
			end
		end
		DrawMarker(1, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 168, 104, 40, 255, 0, 0, 0, 0)
		
		--AdminBuildingExit
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z) < 1.6 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to catch elevator to exit.")
			if IsControlJustReleased(0, Keys['E']) then
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingEntranceCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingEntranceHeading)
				DoScreenFadeIn(5000)
			end
		end
		DrawMarker(1, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z-1, 0, 0, 0, 0, 0, 0, 3.0000, 3.0000, 0.5001, 0, 255, 0, 255, 0, 0, 0, 0)
		
		--AdminBuildingReceptionDesk
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingReceptionDeskCoords.x, AdminBuildingReceptionDeskCoords.y, AdminBuildingReceptionDeskCoords.z) < 1 and not menuopen then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to open the admin request menu!")
			if IsControlJustReleased(1, Keys['E']) then
				if menuopen or admincalled or (designatedroom ~= "") then
				TriggerEvent('chat:addMessage', {
					color = { 255, 0, 0},
					multiline = true,
					args = {"System", "You have already called for an admin, please back to room ".. designatedroom .."!"}})
					
					if designatedroom == "2A" then
						SetNewWaypoint(AdminRoom2ACoords.x, AdminRoom2ACoords.y);
					elseif designatedroom == "2B" then
						SetNewWaypoint(AdminRoom2BCoords.x, AdminRoom2BCoords.y);
					elseif designatedroom == "2C" then
						SetNewWaypoint(AdminRoom2CCoords.x, AdminRoom2CCoords.y);
					elseif designatedroom == "2D" then
						SetNewWaypoint(AdminRoom2DCoords.x, AdminRoom2DCoords.y);
					end
				else
					menuopen = true
					TriggerEvent("ShowARM")
					SetNuiFocus(true, true)
				end
			end
		end
		DrawMarker(1, AdminBuildingReceptionDeskCoords.x, AdminBuildingReceptionDeskCoords.y, AdminBuildingReceptionDeskCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 255, 0, 0, 255, 0, 0, 0, 0)
	end
end)

All of them do this!

try replacing the first two with this and let me know if it works, Ill sort the 3rd one out if this works.

Put this local at the top of the client:

local PressedE = false

Replace firs two with this:

		--AdminBuildingEntrance
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z) < 1 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to enter the admin building")
            if IsControlJustReleased(0, Keys['E']) and not PressedE then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingInsideCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingInsideHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 168, 104, 40, 255, 0, 0, 0, 0)
		
		--AdminBuildingExit
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z) < 1.6 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to catch elevator to exit.")
            if IsControlJustReleased(0, Keys['E']) and not PressedE then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingEntranceCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingEntranceHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z-1, 0, 0, 0, 0, 0, 0, 3.0000, 3.0000, 0.5001, 0, 255, 0, 255, 0, 0, 0, 0)
		

Okay, im checking now.

Still does it.
I added print(“yolo”) to check if it happens, and it does.

	--AdminBuildingEntrance
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z) < 1 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to enter the admin building")
            if IsControlJustReleased(0, Keys['E']) and not PressedE then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingInsideCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingInsideHeading)
                DoScreenFadeIn(5000)
				print("yolo")
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 168, 104, 40, 255, 0, 0, 0, 0)
		
		--AdminBuildingExit
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z) < 1.6 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to catch elevator to exit.")
            if IsControlJustReleased(0, Keys['E']) and not PressedE then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingEntranceCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingEntranceHeading)
                DoScreenFadeIn(5000)
				print("yolo")
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z-1, 0, 0, 0, 0, 0, 0, 3.0000, 3.0000, 0.5001, 0, 255, 0, 255, 0, 0, 0, 0)

The print is getting printed 2 times in my console.

try this one:

		--AdminBuildingEntrance
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z) < 1 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to enter the admin building")
            if not PressedE and IsControlJustPressed(0, Keys['E']) then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingInsideCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingInsideHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 168, 104, 40, 255, 0, 0, 0, 0)
		
		--AdminBuildingExit
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z) < 1.6 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to catch elevator to exit.")
            if not PressedE and IsControlJustPressed(0, Keys['E']) then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingEntranceCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingEntranceHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z-1, 0, 0, 0, 0, 0, 0, 3.0000, 3.0000, 0.5001, 0, 255, 0, 255, 0, 0, 0, 0)
		

Still does it.
Its really weird, because you see there is Citizen.Wait and i put the print(“yolo”) just before it, and it prints yolo 2 times before the citizen wait has passed!

--AdminBuildingEntrance
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z) < 1 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to enter the admin building")
            if not PressedE and IsControlJustPressed(0, Keys['E']) then
                PressedE = true
				print("yolo")
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingInsideCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingInsideHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 168, 104, 40, 255, 0, 0, 0, 0)
		
		--AdminBuildingExit
		if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z) < 1.6 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to catch elevator to exit.")
            if not PressedE and IsControlJustPressed(0, Keys['E']) then
                PressedE = true
				print("yolo")
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingEntranceCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingEntranceHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z-1, 0, 0, 0, 0, 0, 0, 3.0000, 3.0000, 0.5001, 0, 255, 0, 255, 0, 0, 0, 0)

I don’t think its you’r keyboard since having the PressedE should block you from pressing it twice, You don’t have 2 of the same resources do you? lol

You could also try adding a Citizen.Wait(100) under the PressedE = true on both of them, I can’t see it doing much but it could do something i guess, Also it would have printed yolo before the Citizen wait since you put it above the Citizen.Wait

I will add it, but i was saying that yolo ran twice before the timer expired.
With the Citizen.Wait(100) under the PressedE = true nothing changes.

try this:

		--AdminBuildingEntrance
		if not PressedE and GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z) < 1 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to enter the admin building")
            if not PressedE and IsControlJustPressed(0, Keys['E']) then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingInsideCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingInsideHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingEntranceCoords.x, AdminBuildingEntranceCoords.y, AdminBuildingEntranceCoords.z-1, 0, 0, 0, 0, 0, 0, 1.5001, 1.5001, 0.5001, 168, 104, 40, 255, 0, 0, 0, 0)
		
		--AdminBuildingExit
		if not PressedE and GetDistanceBetweenCoords(pos.x, pos.y, pos.z, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z) < 1.6 then
			ESX.ShowHelpNotification("Click ~INPUT_PICKUP~ to catch elevator to exit.")
            if not PressedE and IsControlJustPressed(0, Keys['E']) then
                PressedE = true
				DoScreenFadeOut(3000)
				Citizen.Wait(4000)
				SetEntityCoords(PlayerPedId(), AdminBuildingEntranceCoords)
				SetEntityHeading(PlayerPedId(), AdminBuildingEntranceHeading)
                DoScreenFadeIn(5000)
                PressedE = false
			end
		end
		DrawMarker(1, AdminBuildingInsideCoords.x-0.45, AdminBuildingInsideCoords.y-0.03, AdminBuildingInsideCoords.z-1, 0, 0, 0, 0, 0, 0, 3.0000, 3.0000, 0.5001, 0, 255, 0, 255, 0, 0, 0, 0)
		

Same thing, still printing yolo 2 times

If you send me you’r server IP in a message i will come on there and see if it also does it for me, just to rule that out

For everyone here it is kida6a.eu

You can try to had a bool for distance:
I’m on my phone sorry.

local entrance = false

if getdistance.... then 
    entrance = true
        if iscontroljustpressed... and entrance then
            your code
         end
else
    entrance =false
end

It runs twice despite this bool :expressionless:

Hi, yes sorry it’s useless.You should use a boolean for “iscontroljustpressed” to avoid spamming.

It runs twice despite this bool :expressionless:

Have you tried with an other native like “IsControlJustReleased”?