Why Does This Script Not Work?

It is a child of the vehicle seat.

local seat = script.Parent
local UserInputService = game:GetService("UserInputService")

seat.ChildAdded:Connect(function(child)
	if child.Name == "SeatWeld" then
		local player = game:GetService("Players"):GetPlayerFromCharacter(child.Part1.Parent)
		if player ~= nil then

		end
	end
end)
-- Start of bit that doesn't work
local function onInputBegan(input, _gameProcessed) 
	if input.KeyCode == Enum.KeyCode.H then
		script.Parent.Horn:Play()
	end
end
UserInputService.InputBegan:Connect(onInputBegan)
-- End of broken bit
seat.ChildRemoved:Connect(function(child)
	if child.Name == "SeatWeld" then
		local player = game:GetService("Players"):GetPlayerFromCharacter(child.Part1.Parent)
		if player ~= nil then

		end
	end
end)

Is it in a local script?
(aaaaaaaaa char limit)

No it isn’t but I’ll make it one.

if the run context even set to client

I have no idea what that means

in the properties of the script, you will see RunContext

Ok so, delete the broken bit of the script. then make a RemoteEvent called “HornBegan” and another called “HornStopped” inside the seat. Now make a local script with this code:

local function onInputBegan(input, _gameProcessed) 
	if input.KeyCode == Enum.KeyCode.H then
		script.Parent.HornBegan:FireServer()
	end
end
UserInputService.InputBegan:Connect(onInputBegan)

Now make a variable inside the server script. Call it “PlayerOnSeat” (set it to nil). When someone gets into a seat make it the players name (after the player nil thing) And when they get out make it nil (after the player nil thing again). And then put this piece of code inside the server script:

script.Parent.HornBegan.OnServerEvent:Connect(player)
if player.Name == PlayerOnSeat then
script.Parent.Horn:Play()
end
end)

Keep in mind that theres no pausing so tell me if you want the horn pause (xd)