local k=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local t=game:GetService("\083\101\114\118\101\114\083\116\111\114\097\103\101")local Z=require(script.Parent:WaitForChild("\076\105\103\104\116\115",5))local F=require(script.Parent:WaitForChild("\083\105\114\101\110\115",5))local D=require(k:WaitForChild("\078\101\118\101\114\109\111\114\101",2))local J=D("\083\116\100")local u=J.rquery local m=D("\067\111\109\112\111\110\101\110\116\066\097\115\101")local a=m.new("\069\108\115\072\117\100",{"\101\108\115\104\117\100"})function a._attachElsGuiToVehicleSeatOccupant(Z,F)local D=((t:WaitForChild("\085\115\101\114\073\110\116\101\114\102\097\099\101\115")):WaitForChild("\069\108\115\072\117\100")):Clone()D.Vehicle.Value=Z local J=((k:WaitForChild("\069\113\117\105\112\109\101\110\116",2)):WaitForChild("\069\108\115\072\117\100\066\117\116\116\111\110\115")):Clone()J.Parent=D D.Parent=F.PlayerGui D.ElsHudButtons.Disabled=false end function a._attachVehicleSeatHandlers(k)local t=k:WaitForChild("\086\101\104\105\099\108\101\083\101\097\116")local Z=function(t)if t=="\079\099\099\117\112\097\110\116"and u.GetPlayerDrivingVehicle(k)~=nil then local t=u.GetPlayerDrivingVehicle(k)a._attachElsGuiToVehicleSeatOccupant(k,t)end end t.Changed:Connect(Z)end function a.Execute(t,k)t._attachVehicleSeatHandlers(k)Z:TryExecute(k)F:TryExecute(k)end return a
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local lightsComponent = require(script.Parent:WaitForChild("Lights", 5))
local sirenComponent = require(script.Parent:WaitForChild("Sirens", 5))

local require = require(ReplicatedStorage:WaitForChild("Nevermore", 2))

local std = require("Std")
local rq = std.rquery

local ComponentBase = require("ComponentBase")
local component = ComponentBase.new("ElsHud", {"elshud"})

function component._attachElsGuiToVehicleSeatOccupant(vehicleModel, occupantPlayer)
    local elsHud = ServerStorage:WaitForChild("UserInterfaces"):WaitForChild("ElsHud"):Clone()
    elsHud.Vehicle.Value = vehicleModel
    local elsButtons = ReplicatedStorage:WaitForChild("Equipment", 2):WaitForChild("ElsHudButtons"):Clone()
    elsButtons.Parent = elsHud
    elsHud.Parent = occupantPlayer.PlayerGui
    elsHud.ElsHudButtons.Disabled = false
end

function component._attachVehicleSeatHandlers(vehicleModel)
    local vehicleSeat = vehicleModel:WaitForChild("VehicleSeat")
    local seatOccupantChangedHandler = function(changedProperty)
        if changedProperty == "Occupant" and rq.GetPlayerDrivingVehicle(vehicleModel) ~= nil then
            local occupantPlayer = rq.GetPlayerDrivingVehicle(vehicleModel)
            component._attachElsGuiToVehicleSeatOccupant(vehicleModel, occupantPlayer)
        end
    end
    vehicleSeat.Changed:Connect(seatOccupantChangedHandler)
end

function component:Execute( gameObject )
    self._attachVehicleSeatHandlers(gameObject)
    lightsComponent:TryExecute(gameObject)
    sirenComponent:TryExecute(gameObject)
 end

return component