local R={}function R.GetActionInput(R,M)local e="\110\105\108"local l={Zero="\048",One="\049";Two="\050",Three="\051",Four="\052";Five="\053",Six="\054",Seven="\055";Eight="\056",Nine="\057";MouseButton1="\077\066\049",MouseButton2="\077\066\050";MouseButton3="\077\066\051";Return="\069\110\116\101\114";Slash="\047";Tilde="~";Backquote="\096"}if actions[M]then local R,l=actions[M].Primary,actions[M].Secondary if R then e=R.Name elseif l then e=l.Name end end if l[e]then e=l[e]end return string.upper(e)end if not initialized then local M=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")R.KeybindChanged=M.Event actionBegan=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")actionEnded=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")R.ActionBegan=actionBegan.Event R.ActionEnded=actionEnded.Event local e=PLAYER_DATA:WaitForChild(PLAYER.Name)local l=e:WaitForChild("\075\101\121\098\105\110\100\115")local function r(R,e,l)local r,Z if e then local R,M=string.match(e,"\040\046-\041\037\046\040\046\043\041")if R and M then r=Enum[R][M]end end if l then local R,M=string.match(l,"\040\046-\041\037\046\040\046\043\041")if R and M then Z=Enum[R][M]end end RegisterAction(R,r,Z)M:Fire(R)end local function Z(R)local M=R.Name local e=R.Value if string.match(e,"\059")then local R,l=string.match(e,"\040\046-\041\059\040\046\043\041")if R and l then r(M,R,l)elseif R then r(M,R)elseif l then r(M,nil,l)end else r(M,e)end end l.ChildAdded:connect(function(R)R.Changed:connect(function()Z(R)end)RunService.Stepped:wait()Z(R)end)repeat RunService.Stepped:wait()until#l:GetChildren()>0 for R,M in pairs(l:GetChildren())do M.Changed:connect(function()Z(M)end)Z(M)end initialized=true end return R


local INPUT	= {}

function INPUT.GetActionInput(self, action)
	local input	= "nil"
	
	local replacements	= {
		Zero	= "0";
		One		= "1";
		Two		= "2";
		Three	= "3";
		Four	= "4";
		Five	= "5";
		Six		= "6";
		Seven	= "7";
		Eight	= "8";
		Nine	= "9";
		
		MouseButton1	= "MB1";
		MouseButton2	= "MB2";
		MouseButton3	= "MB3";
		Return			= "Enter";
		Slash			= "/";
		Tilde			= "~";
		Backquote		= "`";
	}
	
	if actions[action] then
		local primary, secondary	= actions[action].Primary, actions[action].Secondary
		
		if primary then
			input	= primary.Name
		elseif secondary then
			input	= secondary.Name
		end
	end
	
	if replacements[input] then
		input	= replacements[input]
	end
	
	return string.upper(input)
end

if not initialized then
	local keybindChanged	= Instance.new("BindableEvent")
	INPUT.KeybindChanged	= keybindChanged.Event
	
	actionBegan	= Instance.new("BindableEvent")
	actionEnded	= Instance.new("BindableEvent")
	
	INPUT.ActionBegan	= actionBegan.Event
	INPUT.ActionEnded	= actionEnded.Event
	
	-- register actions
	
	local playerData	= PLAYER_DATA:WaitForChild(PLAYER.Name)
	local keybinds		= playerData:WaitForChild("Keybinds")
	
	local function Register(action, bindP, bindS)
		local primary, secondary
		if bindP then
			local A, B	= string.match(bindP, "(.-)%.(.+)")
			
			if A and B then
				primary	= Enum[A][B]
			end
		end
		if bindS then
			local A, B	= string.match(bindS, "(.-)%.(.+)")
			
			if A and B then
				secondary	= Enum[A][B]
			end
		end
		
		RegisterAction(action, primary, secondary)
		keybindChanged:Fire(action)
	end
	
	local function Handle(keybind)
		local action	= keybind.Name
		local bind		= keybind.Value
		
		if string.match(bind, ";") then
			local bindP, bindS	= string.match(bind, "(.-);(.+)")
			
			if bindP and bindS then
				Register(action, bindP, bindS)
			elseif bindP then
				Register(action, bindP)
			elseif bindS then
				Register(action, nil, bindS)
			end
		else
			Register(action, bind)
		end
	end
	
	keybinds.ChildAdded:connect(function(keybind)
		keybind.Changed:connect(function()
			Handle(keybind)
		end)
		
		RunService.Stepped:wait()
		Handle(keybind)
	end)
	
	repeat
		RunService.Stepped:wait()
	until #keybinds:GetChildren() > 0
	
	for _, keybind in pairs(keybinds:GetChildren()) do
		keybind.Changed:connect(function()
			Handle(keybind)
		end)
		
		Handle(keybind)
	end
	
	initialized			= true
end

return INPUT
