Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

J for turning on off lights in vehicles?

Asked by 4 years ago

I am making a DOT (Department of transportation) ford f350, the lights flash but I ney a keybind for on/off lighting, but i have no idea where to put it I know the script Enum.KeyCode.(button)

1 answer

Log in to vote
0
Answered by
palav 104
4 years ago

Before you connect this code, make sure that the player is actually in the car, else they'll be able to turn the lights on/off even if they're not driving. This should also go in a local script. This script also assumes that you have a function for turning the lights on and off. Didn't test this so watch out for spelling mistakes.

local UIS = game:GetService("UserInputService")
local LightsAreOn = false

UIS.InputBegan:Connect(function(Input, GSE)
    if Input.Keycode = Enum.KeyCode.J then
        if LightsAreOn then
            LightsOn()
            LightsAreOn = true
        else
            LightsOff()
            LightsAreOn = false
        end
    end
end)
0
Thanks, Everything is spelled right, put this in the a chassi or lightbar? RandomPoliceUser 2 — 4y
0
Doesn't matter. Just check if the player is driving before you run the code. Also this probably won't work if filtering enabled is on, so use RemoteEvents to turn off/on the lights if your games uses FE. palav 104 — 4y
Ad

Answer this question