0% found this document useful (0 votes)
16 views

Handler

The document contains functions for controlling the lights of a vehicle in a game. It defines functions to update different types of lights and turn them on or off. It also contains functions for blinking lights and toggling side lights.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Handler

The document contains functions for controlling the lights of a vehicle in a game. It defines functions to update different types of lights and turn them on or off. It also contains functions for blinking lights and toggling side lights.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

local F = {}

local body = script.Parent.Parent.Parent.Body.Lights


local misc = script.Parent.Parent.Parent.Misc
local car = script.Parent.Parent.Parent
local BlinkersEnabled = true
local player = nil

F.updateLights = function(lights, bool)

if lights == 'brake' then


body.Brake.Transparency = bool and 0.1 or 1
misc.Trunk.Brake2.Transparency = bool and 0.1 or 1
body.L1L.Transparency = bool and 0.1 or 1
body.L2L.Transparency = bool and 0.1 or 1
body.L3L.Transparency = bool and 0.1 or 1
body.L4L.Transparency = bool and 0.1 or 1
body.R1R.Transparency = bool and 0.1 or 1
body.R2R.Transparency = bool and 0.1 or 1
body.R3R.Transparency = bool and 0.1 or 1
body.R4R.Transparency = bool and 0.1 or 1
body.RBB.Transparency = bool and 0.1 or 1
body.BL1.Light.Enabled = bool
body.BL2.Light.Enabled = bool
body.BL3.Light.Enabled = bool
body.BL4.Light.Enabled = bool

elseif lights == 'beam' then


car.DriveSeat.BLINKL.Value = bool
body.DRL.Transparency = bool and 1 or 0.1
body.Beams.Lowbeam1.Beam.Enabled = bool
body.Beams.Lowbeam2.Beam.Enabled = bool
body.FB.Transparency = bool and 0.1 or 1
body.RB.Transparency = bool and 0.1 or 1
body.RB2.Transparency = bool and 0.1 or 1
body.L1LL.Transparency = bool and 0.1 or 1
body.L2Ll.Transparency = bool and 0.1 or 1
body.L3LL.Transparency = bool and 0.1 or 1
body.L4LL.Transparency = bool and 0.1 or 1
body.R1RR.Transparency = bool and 0.1 or 1
body.R2RR.Transparency = bool and 0.1 or 1
body.R3RR.Transparency = bool and 0.1 or 1
body.R4RR.Transparency = bool and 0.1 or 1
body.RBBB.Transparency = bool and 0.1 or 1
misc.Trunk.RBMisc.Transparency = bool and 0.1 or 1
body.FB1.Transparency = bool and 0.1 or 1
body.FB2.Transparency = bool and 0.1 or 1
body.RBL1.Light.Enabled = bool
body.RBL2.Light.Enabled = bool
body.RBL3.Light.Enabled = bool
body.RBL4.Light.Enabled = bool
body.L0.Light.Enabled = bool
body.L1.Light.Enabled = bool
misc.Trunk.Platrear1.Transparency = bool and 0.1 or 1
misc.Trunk.Platrear2.Transparency = bool and 0.1 or 1
misc.Trunk.Platrear2.Light.Enabled = bool
misc.Trunk.Platrear1.Light.Enabled = bool
body.Redlight.Transparency = bool and 0.1 or 1
body.Whitelight.Transparency = bool and 0.1 or 1
misc.FORTUNE.Steering_Wheel.Parts.Steering.Light.Transparency = bool
and 0.1 or 1
elseif lights == 'Int' then
body.intF1.Transparency = bool and 0.1 or 1
body.intF2.Transparency = bool and 0.1 or 1
body.intM.Transparency = bool and 0.1 or 1
body.intR.Transparency = bool and 0.1 or 1
body.intF1.Light.Enabled = bool
body.intF2.Light.Enabled = bool
body.intM.Light.Enabled = bool
body.intR.Light.Enabled = bool
elseif lights == 'Fog' then
body.Fog.Transparency = bool and 0.1 or 1
body.Fog1.Light.Enabled = bool
body.Fog2.Light.Enabled = bool
body.Beams.Fogbeam1.Beam.Enabled = bool
body.Beams.Fogbeam2.Beam.Enabled = bool
elseif lights == 'Projie' then
body.Projie1.Transparency = bool and 0.1 or 1
body.Projie2.Transparency = bool and 0.1 or 1
body.Projie3.Transparency = bool and 0.1 or 1
body.Projie4.Transparency = bool and 0.1 or 1
body.Projie1.SpotLight.Enabled = bool
body.Projie2.SpotLight.Enabled = bool
body.Projie3.SpotLight.Enabled = bool
body.Projie4.SpotLight.Enabled = bool
body.Beams.Projiebeam1.Beam.Enabled = bool
body.Beams.Projiebeam2.Beam.Enabled = bool
body.Beams.Projiebeam3.Beam.Enabled = bool
body.Beams.Projiebeam4.Beam.Enabled = bool
elseif lights == 'highbeam' then
body.High3.Transparency = bool and 0.1 or 1
body.High4.Transparency = bool and 0.1 or 1
body.High5.Transparency = bool and 0.1 or 1
body.High6.Transparency = bool and 0.1 or 1
body.High1.Light.Enabled = bool
body.High2.Light.Enabled = bool
body.High3.Light.Enabled = bool
body.High4.Light.Enabled = bool
body.High5.Light.Enabled = bool
body.High6.Light.Enabled = bool
body.Beams.Highbeam1.Beam.Enabled = bool
body.Beams.Highbeam2.Beam.Enabled = bool
body.Beams.Highbeam3.Beam.Enabled = bool
body.Beams.Highbeam4.Beam.Enabled = bool
body.Beams.Highbeam5.Beam.Enabled = bool
body.Beams.Highbeam6.Beam.Enabled = bool
elseif lights == 'drl' then
if bool == true then
body.Startupscreen.Transparency = 0
body.First.Transparency = 1
wait(0.5)
body.Speedometer.Transparency = 0
body.DRL.Transparency = 0.1
body.Blueint.Transparency = 0
misc.Speedo.Parts.Needle.Transparency = 0
misc.Tach.Parts.Needle.Transparency = 0
body.Second.Transparency = 0
wait(1.5)
body.Second.Transparency = 0.1
wait(0.1)
body.Second.Transparency = 0.2
wait(0.1)
body.Second.Transparency = 0.3
wait(0.1)
body.Second.Transparency = 0.4
wait(0.1)
body.Second.Transparency = 0.5
wait(0.1)
body.Second.Transparency = 0.6
wait(0.1)
body.Second.Transparency = 0.7
wait(0.1)
body.Second.Transparency = 0.8
wait(0.1)
body.Second.Transparency = 0.9
wait(0.1)
body.Second.Transparency = 1
body.Mainscreen.Transparency = 0
body.Bluelight.Transparency = 0
body.Lightbluelight.Transparency = 0.1
wait(0.1)
body.Third.Transparency = 0.9
wait(0.1)
body.Third.Transparency = 0.8
wait(0.1)
body.Third.Transparency = 0.7
wait(0.1)
body.Third.Transparency = 0.6
wait(0.1)
body.Third.Transparency = 0.5
wait(0.1)
body.Third.Transparency = 0.4
wait(0.1)
body.Third.Transparency = 0.3
wait(0.1)
body.Third.Transparency = 0.2
wait(0.1)
body.Third.Transparency = 0.1
wait(0.1)
body.Third.Transparency = 0

else
body.DRL.Transparency = 1
body.Startupscreen.Transparency = 1
body.Mainscreen.Transparency = 1
body.Second.Transparency = 1
body.Third.Transparency = 1
body.Blueint.Transparency = 1
misc.Speedo.Parts.Needle.Transparency = 1
misc.Tach.Parts.Needle.Transparency = 1
body.Bluelight.Transparency = 1
body.Lightbluelight.Transparency = 1
body.Redlight.Transparency = 1
body.Whitelight.Transparency = 1
body.Speedometer.Transparency = 1
misc.FORTUNE.Steering_Wheel.Parts.Steering.Light.Transparency = 1

end
elseif lights == 'reverse' then
body.RV.Transparency = bool and 0.1 or 1
body.RV.Light.Enabled = bool
end
end

local b = ''

function optwait(sec,opt)
if opt then
wait(sec)
end
end

function blinkL (dir, tog)

if dir == 'Left' and car.DriveSeat.BLINKL.Value == true then


body.FB1.Transparency = tog and 0 or 1

elseif dir == 'Right' and car.DriveSeat.BLINKL.Value == true then


body.FB2.Transparency = tog and 0 or 1

elseif dir == 'Hazards' and car.DriveSeat.BLINKL.Value == true then


body.FB1.Transparency = tog and 0 or 1
body.FB2.Transparency = tog and 0 or 1

end
end

function Toggle(dir, tog)

if dir == 'Left' then


body.FL.Transparency = tog and 0.1 or 1
body.intleft.Transparency = tog and 0.1 or 1
misc.FLdoor.ML.Transparency = tog and 0.1 or 1
body.RL.Transparency = tog and 0.1 or 1
misc.Trunk.RLMisc.Transparency = tog and 0.1 or 1

car.DriveSeat.LI.Value = tog
elseif dir == 'Right' then
body.FR.Transparency = tog and 0.1 or 1
body.intright.Transparency = tog and 0.1 or 1
misc.FRdoor.MR.Transparency = tog and 0.1 or 1
body.RR.Transparency = tog and 0.1 or 1
misc.Trunk.RRMisc.Transparency = tog and 0.1 or 1

car.DriveSeat.RI.Value = tog
elseif dir == 'Hazards' then
body.FL.Transparency = tog and 0.1 or 1
body.intleft.Transparency = tog and 0.1 or 1
body.intright.Transparency = tog and 0.1 or 1
misc.FLdoor.ML.Transparency = tog and 0.1 or 1
body.RL.Transparency = tog and 0.1 or 1
body.FR.Transparency = tog and 0.1 or 1
misc.FRdoor.MR.Transparency = tog and 0.1 or 1
body.RR.Transparency = tog and 0.1 or 1
misc.Trunk.RRMisc.Transparency = tog and 0.1 or 1
misc.Trunk.RLMisc.Transparency = tog and 0.1 or 1
car.DriveSeat.LI.Value = tog
car.DriveSeat.RI.Value = tog
end
end

function blink(typ)
b = typ
if blinking == true then
blinking = false
else
blinking = true
blinkL(typ, false)
while blinking do
Toggle(typ, true)
script.Parent:FireClient(player, 'blink', .9, true)
wait(1/3)
Toggle(typ, false)
script.Parent:FireClient(player, 'blink', 0.8, true)
wait(1/3)
end
Toggle(typ, false)
script.Parent:FireClient(player, 'blink', .9, false)
wait(1/9)
blinkL(typ, true)

end
end

script.Parent.Parent.ChildRemoved:connect(function(child)
if child:IsA("Weld") and BlinkersEnabled then
if blinking == true and b == 'Hazards' then
return
else
blinking = false
end
end
end)

F.blinkers = function(dir)
blink(dir)
end

script.Parent.Parent.DRL.Changed:Connect(function()--CAR IGNITION STATUS TOGGLE


if script.Parent.Parent.DRL.Value == true then
F.updateLights('drl', true)
else
F.updateLights('drl', false)
end
end)

F.lockflash = function()
Toggle('Hazards', true)
wait(1/3)
Toggle('Hazards', false)
end

F.unlockflash = function()
Toggle('Hazards', true)
wait(1/3)
Toggle('Hazards', false)
wait(1/3)
Toggle('Hazards', true)
wait(1/3)
Toggle('Hazards', false)

end

script.Parent.OnServerEvent:connect(function(pl,Fnc,...)
player = pl
F[Fnc](...)
end)

You might also like