wait(.1)local F=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local G=require(F:WaitForChild("\078\101\118\101\114\109\111\114\101",2))local h=G("\080\117\098\083\117\098")local l=game:GetService("\082\117\110\083\101\114\118\105\099\101")local d=game.Players.LocalPlayer local o=workspace:WaitForChild(d.Name)local O=script.Parent.Vehicle.Value local y=O:WaitForChild("\086\101\104\105\099\108\101\083\101\097\116")local M=o:WaitForChild("\072\117\109\097\110\111\105\100")local e=""if O:FindFirstChild("\069\110\116\105\116\121\073\100")then e=(O:FindFirstChild("\069\110\116\105\116\121\073\100")).Value else error("\077\105\115\115\105\110\103 \117\110\105\113\117\101 \105\100\101\110\116\105\102\105\101\114 \069\110\116\105\116\121\073\100 \111\110 \109\111\100\101\108\058 "..O.Name)end local function t(F,G)local l=h.GetOrCreateClientServerTopicInCategory("\069\076\083",G.Text)print(l.Name)local d=function(h)l:FireServer(F)print("\082\101\099\101\105\118\101\100 \099\108\105\099\107 \102\114\111\109 \101\110\116\105\116\121\058 "..(F..(" \111\110 \098\117\116\116\111\110\058 "..G.Text)))end return d end local L=(script.Parent:FindFirstChild("\072\117\100\070\114\097\109\101")):GetChildren()local function n(F,G)if G:IsA("\071\117\105\066\117\116\116\111\110")then G.Activated:Connect(t(F,G))print("\065\100\100\101\100 \100\101\108\101\103\097\116\101 \104\097\110\100\108\101\114 \116\111 \098\117\116\116\111\110\058 "..G.Name)end end for F,G in pairs(L)do print("\067\111\110\110\101\099\116\105\110\103 \098\117\116\116\111\110\058 "..G.Name)n(e,G)end l.RenderStepped:Connect(function()if M.SeatPart~=y or M.Health<=0 then script.Parent.Parent=nil script:Destroy()end end)
wait(0.1)

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

local pubSubClient = require("PubSub")
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Model = script.Parent.Vehicle.Value

local VehicleSeat = Model:WaitForChild("VehicleSeat")
local Humanoid = Character:WaitForChild("Humanoid")

local entityId = ""

if Model:FindFirstChild("EntityId") then
    entityId = Model:FindFirstChild("EntityId").Value
else
	error("Missing unique identifier EntityId on model: " .. Model.Name)
end

local function generateDelegate(entityId, button)
    local topic = pubSubClient.GetOrCreateClientServerTopicInCategory("ELS", button.Text)
    print(topic.Name)
	local activatedDelegate = function(sender)
        topic:FireServer(entityId)
		print("Received click from entity: " .. entityId .. " on button: " .. button.Text)
	end
	return activatedDelegate
end

local buttons = script.Parent:FindFirstChild("HudFrame"):GetChildren()

local function connectButton(entityId, button)
    if button:IsA("GuiButton") then
		button.Activated:Connect(generateDelegate(entityId, button))
		print("Added delegate handler to button: " .. button.Name)
    end
end

for _, btn in pairs(buttons) do
    print("Connecting button: " .. btn.Name)
    connectButton(entityId, btn)
end

RunService.RenderStepped:Connect(function()
	if Humanoid.SeatPart ~= VehicleSeat or Humanoid.Health <= 0 then
		script.Parent.Parent = nil
		script:Destroy()
	end
end)