[HELP] Undercover Civilian Vehicles

I’ve been working on this script now for the past 20 minutes and I can’t figure it out.
This is my code:

local emergl = false

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsPedInAnyVehicle(GetPlayerPed(-1), false) and GetPedInVehicleSeat(-1, GetPlayerPed(-1))then
			if IsControlJustPressed(0, 311) then
				if emergl == false then
				emergl = true
					while emergl == true then
						SetVehicleNeonLightsColour(GetVehiclePedIsUsing(GetPlayerPed(-1)), 255, 0, 0)
						SetVehicleNeonLightEnabled(GetVehiclePedIsUsing(GetPlayerPed(-1)), 0, true)
						SetVehicleNeonLightEnabled(GetVehiclePedIsUsing(GetPlayerPed(-1)), 1, true)
						SetVehicleNeonLightEnabled(GetVehiclePedIsUsing(GetPlayerPed(-1)), 2, true)
						SetVehicleNeonLightEnabled(GetVehiclePedIsUsing(GetPlayerPed(-1)), 3, true)
						Citizen.Wait(500)
						SetVehicleNeonLightsColour(GetVehiclePedIsUsing(GetPlayerPed(-1)), 0, 0, 255)
						Citizen.Wait(500)
						end
					end
				end
			end
		end
	end
end)

No errors but still doesnt work. I would love some help. Thanks

Moved to #development:scripts as this is not a release.

Please post in the correct category next time :mascot:

Thats my bad, I thought I posted it at the right place. :mascot:
Sh!t, That got big

Ah I see, you have one too many end statements, fix your indentation to easily spot these issues (and use a sane code editor, Visual Studio Code is the best imo).

I usually gets error for not having enough end. Thanks in advance.

I tried to remove some ends but still doesnt work. No errors either? Any other idea?

maybe try removing the actual needed amount?

1 Like

You should see what does get executed, add some prints after every if statement so you can see the code path :slight_smile:

2 Likes

The Cool Kiddo Viggo Solved it with help from https://forum.cfx.re/u/Syntasu https://forum.cfx.re/u/IceHax