Roblox Client Side to Server Side

How could I convert this into a server side script?

local userInputService = game:GetService("UserInputService")
local seat = script.Parent.Seat.Value
local UpdateTrain = seat.UpdateTrain
local Functions = seat.Parent.Functions
horn = true
bell = false

ditchlights = false

userInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.D then
		if ditchlights == false then
			print("Ditchlights On")
			Functions.Ditchlights.Value = true
			ditchlights = true
		else
			print("Ditchlights Off")
			Functions.Ditchlights.Value = false
			ditchlights = false
		end
	end
	if input.KeyCode == Enum.KeyCode.B then
		if bell == false then
			print("Bell On")
			bell = true
		else
			print("Bell Off")
			bell = false
		end
	end
end)

What exactly do you want to do? As far as I know, UserInputService is not available on the server and the only option is Events.

You will have to use Remove events

Is there a way I can make all of this work with 1 remote event and not multiple?

Here you go


-- client
game.ReplicatedStorage.ToggleLightsRemote:FireServer(state : boolean)
game.ReplicatedStorage.ToggleBellRemote:FireServer(state : boolean)

-- server
game.ReplicatedStorage.ToggleLightsRemote.OnServerEvent:Connect(function(state)
Ditchlights.Enabled = state
end)

game.ReplicatedStorage.ToggleBellRemote.OnServerEvent:Connect(function(state)
Bell.Enabled = state
end)

You could always send more variables, change the remote to be ‘toggleDevice’ and then send over (device_name : string, state : boolean)