local x=false local N=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local M=0 local f=0 local R=0 local p=0 local h=0 local u=0 local i=0 local y=0 local w=0 local C=0 local a=0 function DealWithInput(N,E)if x then if N.KeyCode==Enum.KeyCode.ButtonX then if N.UserInputState==Enum.UserInputState.Begin then u=1 elseif N.UserInputState==Enum.UserInputState.End then u=0 end elseif N.KeyCode==Enum.KeyCode.ButtonY then if N.UserInputState==Enum.UserInputState.Begin then i=1 elseif N.UserInputState==Enum.UserInputState.End then i=0 end elseif N.KeyCode==Enum.KeyCode.ButtonL1 then if N.UserInputState==Enum.UserInputState.Begin then y=1 elseif N.UserInputState==Enum.UserInputState.End then y=0 end elseif N.KeyCode==Enum.KeyCode.ButtonR1 then if N.UserInputState==Enum.UserInputState.Begin then w=1 elseif N.UserInputState==Enum.UserInputState.End then w=0 end elseif N.KeyCode==Enum.KeyCode.DPadUp then if N.UserInputState==Enum.UserInputState.Begin then a=1 elseif N.UserInputState==Enum.UserInputState.End then a=0 end elseif N.KeyCode==Enum.KeyCode.ButtonR3 then if N.UserInputState==Enum.UserInputState.Begin then C=1 elseif N.UserInputState==Enum.UserInputState.End then C=0 end end if N.UserInputType.Name:find("\071\097\109\101\112\097\100")then if N.KeyCode==Enum.KeyCode.Thumbstick1 then M=N.Position.X elseif N.KeyCode==Enum.KeyCode.Thumbstick2 then f=N.Position.X R=N.Position.Y elseif N.KeyCode==Enum.KeyCode.ButtonR2 then p=N.Position.Z elseif N.KeyCode==Enum.KeyCode.ButtonL2 then h=N.Position.Z end end end end N.InputBegan:connect(DealWithInput)N.InputChanged:connect(DealWithInput)N.InputEnded:connect(DealWithInput)
---Controller
local Controller = false
local UserInputService = game:GetService("UserInputService")
local LStickX = 0
local RStickX = 0
local RStickY = 0
local RTriggerValue = 0
local LTriggerValue = 0

local ButtonX = 0
local ButtonY = 0
local ButtonL1 = 0
local ButtonR1 = 0
local ButtonR3 = 0
local DPadUp = 0
function DealWithInput(input, IsRobloxFunction)
	if Controller then
		if input.KeyCode == Enum.KeyCode.ButtonX then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonX = 1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonX = 0
			end
		elseif input.KeyCode == Enum.KeyCode.ButtonY then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonY = 1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonY = 0
			end
		elseif input.KeyCode == Enum.KeyCode.ButtonL1 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonL1 = 1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonL1 = 0
			end
		elseif input.KeyCode == Enum.KeyCode.ButtonR1 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonR1 = 1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonR1 = 0
			end
		elseif input.KeyCode == Enum.KeyCode.DPadUp then
			if input.UserInputState == Enum.UserInputState.Begin then
				DPadUp = 1
			elseif input.UserInputState == Enum.UserInputState.End then
				DPadUp = 0
			end
		elseif input.KeyCode == Enum.KeyCode.ButtonR3 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonR3 = 1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonR3 = 0
			end
		end
		if input.UserInputType.Name:find("Gamepad") then --it's one of 4 gamepads
			if input.KeyCode == Enum.KeyCode.Thumbstick1 then
				LStickX = input.Position.X
			elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
				RStickX = input.Position.X
				RStickY = input.Position.Y
			elseif input.KeyCode == Enum.KeyCode.ButtonR2 then --right shoulder
				RTriggerValue = input.Position.Z
			elseif input.KeyCode == Enum.KeyCode.ButtonL2 then --left shoulder
				LTriggerValue = input.Position.Z
			end
		end
	end
end
UserInputService.InputBegan:connect(DealWithInput)
UserInputService.InputChanged:connect(DealWithInput) --keyboards don't activate with Changed, only Begin and Ended. idk if digital controller buttons do too
UserInputService.InputEnded:connect(DealWithInput)
