function convertKey(I)if I==string.char(8)then return"\066\075\083\080\067\069"elseif I==string.char(9)then return"\084\065\066"elseif I==string.char(13)then return"\069\078\084\069\082"elseif I==string.char(17)then return"\085\080"elseif I==string.char(18)then return"\068\079\087\078"elseif I==string.char(19)then return"\082\073\071\072\084"elseif I==string.char(20)then return"\076\069\070\084"elseif I==string.char(22)then return"\072\079\077\069"elseif I==string.char(23)then return"\069\078\068"elseif I==string.char(27)then return"\070\050"elseif I==string.char(29)then return"\070\052"elseif I==string.char(30)then return"\070\053"elseif I==string.char(32)or I==" "then return"\070\055"elseif I==string.char(33)or I=="\033"then return"\070\056"elseif I==string.char(34)or I=="\""then return"\070\057"elseif I==string.char(35)or I=="\035"then return"\070\049\048"elseif I==string.char(37)or I=="\037"then return"\070\049\050"elseif I==string.char(47)or I=="\047"then return"\082-\083\072\073\070\084"elseif I==string.char(48)or I=="\048"then return"\076-\083\072\073\070\084"elseif I==string.char(49)or I=="\049"then return"\082-\067\084\082\076"elseif I==string.char(50)or I=="\050"then return"\076-\067\084\082\076"elseif I==string.char(51)or I=="\051"then return"\082-\065\076\084"elseif I==string.char(52)or I=="\052"then return"\076-\065\076\084"else return string.upper(I)end end function createControlFrame(I,O,o)local v=Instance.new("\070\114\097\109\101")v.BackgroundTransparency=o%2==1 and.7 or 1 v.BorderSizePixel=0 v.Name="\067"..o v.Position=UDim2.new(0,0,0,o*20)v.Size=UDim2.new(1,0,0,20)v.ZIndex=10 local s=Instance.new("\084\101\120\116\076\097\098\101\108")s.BackgroundTransparency=1 s.Name="\075\101\121"s.Size=UDim2.new(0,45,1,0)s.ZIndex=10 s.Font=Enum.Font.ArialBold s.FontSize=Enum.FontSize.Size14 s.Text=I s.TextColor3=Color3.new(1,1,1)s.TextScaled=string.len(I)>5 s.TextWrapped=string.len(I)>5 s.Parent=v local Y=Instance.new("\084\101\120\116\076\097\098\101\108")Y.BackgroundTransparency=1 Y.Name="\068\101\115\099"Y.Position=UDim2.new(0,50,0,0)Y.Size=UDim2.new(1,-50,1,0)Y.ZIndex=10 Y.Font=Enum.Font.SourceSansBold Y.FontSize=Enum.FontSize.Size14 Y.Text="- "..O Y.TextColor3=Color3.new(1,1,1)Y.TextXAlignment=Enum.TextXAlignment.Left Y.Parent=v v.Parent=Controls end function createModes()numModes=0 for I,O in pairs(S.selectFireSettings.Modes)do if O then numModes=numModes+1 end end local I=0 for O,o in pairs(S.selectFireSettings.Modes)do if o then local o=Instance.new("\070\114\097\109\101")o.BackgroundTransparency=1 o.Name=I o.Position=UDim2.new()o.Size=UDim2.new()o.Parent=fireModes local v=Instance.new("\084\101\120\116\076\097\098\101\108")v.BackgroundTransparency=1 v.Name="\076\097\098\101\108"v.Position=UDim2.new(0,-20,0,0)v.Size=UDim2.new(0,40,0,20)v.Font=Enum.Font.SourceSansBold v.FontSize=Enum.FontSize.Size18 v.Text=string.upper(O)v.TextColor3=Color3.new(1,1,1)v.TextScaled=true v.TextStrokeTransparency=0 v.TextTransparency=.5 v.TextWrapped=true v.Parent=o table.insert(Modes,string.upper(O))I=I+1 end end guiAngOffset=((-15*numModes^3+150*numModes^2)-525*numModes)+660 end function setUpGUI()local I=1 for I,O in pairs(Controls:GetChildren())do if O.Name~="\084\105\116\108\101"then O:Destroy()end end for O,o in pairs(Plugins.KeyDown)do createControlFrame(convertKey(o.Key),o.Description,I)I=I+1 end if S.canChangeStance then local O=S.dolphinDive and" \047 \068\105\118\101"or""createControlFrame(convertKey(S.Keys.lowerStance),"\076\111\119\101\114 \083\116\097\110\099\101"..O,I)I=I+1 createControlFrame(convertKey(S.Keys.raiseStance),"\082\097\105\115\101 \083\116\097\110\099\101",I)I=I+1 end if S.selectFire then createControlFrame(convertKey(S.Keys.selectFire),"\083\101\108\101\099\116 \070\105\114\101",I)I=I+1 end createControlFrame(convertKey(S.Keys.Reload),"\082\101\108\111\097\100",I)I=I+1 createControlFrame(convertKey(S.Keys.Sprint),"\083\112\114\105\110\116",I)I=I+1 if S.canADS then local O=S.aimSettings.holdToADS and"\072\079\076\068 "or""if S.Keys.ADS~=""then createControlFrame(O..(convertKey(S.Keys.ADS).." \079\082 \082-\077\079\085\083\069"),"\065\105\109 \068\111\119\110 \083\105\103\104\116\115",I)else createControlFrame(O.." \082-\077\079\085\083\069","\065\105\109 \068\111\119\110 \083\105\103\104\116\115",I)end I=I+1 end Controls.Size=UDim2.new(1,0,0,I*20)Controls.Position=UDim2.new(0,0,0,-(I*20)-80)if S.guiScope then scopeSteady.Text="\072\111\108\100 "..(convertKey(S.Keys.scopeSteady).." \116\111 \083\116\101\097\100\121")end if mainGUI:FindFirstChild("\067\111")then mainGUI.Co:Destroy()end local O=Instance.new("\084\101\120\116\076\097\098\101\108")O.BackgroundTransparency=1 O.Name="\067\111"O.Visible=true O.Position=UDim2.new(0,0,0,0)O.Size=UDim2.new(1,0,0,20)O.Font=Enum.Font.ArialBold O.FontSize=Enum.FontSize.Size14 O.Text=("~ \049\050\053\114\101\100\110\097\088 \038 \116\069\104\089\117\077 \121\098 \101\107\097\109\101\082 \047\047 \110\111\105\115\117\070\111\098\114\117\084 \121\098 \116\105\075 ~"):reverse()O.TextColor3=Color3.new(1,1,1)O.TextStrokeColor3=Color3.new(1,1,1)O.TextStrokeTransparency=.9 O.TextTransparency=.9 O.TextXAlignment=Enum.TextXAlignment.Center O.Parent=mainGUI gunNameTitle.Text=Gun.Name updateClipAmmo()updateStoredAmmo()fireModes:ClearAllChildren()createModes()updateModeLabels(numModes-1,0,90)if S.selectFire then modeGUI.Text=Modes[(rawFireMode-1)%numModes+1]else modeGUI.Text=S.gunType.Semi and"\083\069\077\073"or S.gunType.Auto and"\065\085\084\079"or S.gunType.Burst and"\066\085\082\083\084"or"\083\065\070\069\084\089"end end


function convertKey(Key)
	if Key == string.char(8) then
		return "BKSPCE" 
	elseif Key == string.char(9) then
		return "TAB"
	elseif Key == string.char(13) then
		return "ENTER"
	elseif Key == string.char(17) then
		return "UP"
	elseif Key == string.char(18) then
		return "DOWN"
	elseif Key == string.char(19) then
		return "RIGHT"
	elseif Key == string.char(20) then
		return "LEFT"
	elseif Key == string.char(22) then
		return "HOME"
	elseif Key == string.char(23) then
		return "END"
	elseif Key == string.char(27) then
		return "F2"
	elseif Key == string.char(29) then
		return "F4"
	elseif Key == string.char(30) then
		return "F5"
	elseif Key == string.char(32) or Key == " " then
		return "F7"
	elseif Key == string.char(33) or Key == "!" then
		return "F8"
	elseif Key == string.char(34) or Key == '"' then
		return "F9"
	elseif Key == string.char(35) or Key == "#" then
		return "F10"
	elseif Key == string.char(37) or Key == "%" then
		return "F12"
	elseif Key == string.char(47) or Key == "/" then
		return "R-SHIFT"
	elseif Key == string.char(48) or Key == "0" then
		return "L-SHIFT"
	elseif Key == string.char(49) or Key == "1" then
		return "R-CTRL"
	elseif Key == string.char(50) or Key == "2" then
		return "L-CTRL"
	elseif Key == string.char(51) or Key == "3" then
		return "R-ALT"
	elseif Key == string.char(52) or Key == "4" then
		return "L-ALT"
	else
		return string.upper(Key)
	end
end

function createControlFrame(Key, Desc, Num)
	local C = Instance.new("Frame")
	C.BackgroundTransparency = ((Num % 2) == 1 and 0.7 or 1)
	C.BorderSizePixel = 0
	C.Name = "C"..Num
	C.Position = UDim2.new(0, 0, 0, Num * 20)
	C.Size = UDim2.new(1, 0, 0, 20)
	C.ZIndex = 10
	
	local K = Instance.new("TextLabel")
	K.BackgroundTransparency = 1
	K.Name = "Key"
	K.Size = UDim2.new(0, 45, 1, 0)
	K.ZIndex = 10
	K.Font = Enum.Font.ArialBold
	K.FontSize = Enum.FontSize.Size14
	K.Text = Key
	K.TextColor3 = Color3.new(1, 1, 1)
	K.TextScaled = (string.len(Key) > 5)
	K.TextWrapped = (string.len(Key) > 5)
	K.Parent = C
	
	local D = Instance.new("TextLabel")
	D.BackgroundTransparency = 1
	D.Name = "Desc"
	D.Position = UDim2.new(0, 50, 0, 0)
	D.Size = UDim2.new(1, -50, 1, 0)
	D.ZIndex = 10
	D.Font = Enum.Font.SourceSansBold
	D.FontSize = Enum.FontSize.Size14
	D.Text = "- "..Desc
	D.TextColor3 = Color3.new(1, 1, 1)
	D.TextXAlignment = Enum.TextXAlignment.Left
	D.Parent = C
	
	C.Parent = Controls
end

function createModes()
	numModes = 0
	for i, v in pairs(S.selectFireSettings.Modes) do
		if v then
			numModes = numModes + 1
		end
	end
	
	local currentMode = 0
	for i, v in pairs(S.selectFireSettings.Modes) do
		if v then
			local Frame = Instance.new("Frame")
			Frame.BackgroundTransparency = 1
			Frame.Name = currentMode
			Frame.Position = UDim2.new()
			Frame.Size = UDim2.new()
			Frame.Parent = fireModes
			local modeLabel = Instance.new("TextLabel")
			modeLabel.BackgroundTransparency = 1
			modeLabel.Name = "Label"
			modeLabel.Position = UDim2.new(0, -20, 0, 0)
			modeLabel.Size = UDim2.new(0, 40, 0, 20)
			modeLabel.Font = Enum.Font.SourceSansBold
			modeLabel.FontSize = Enum.FontSize.Size18
			modeLabel.Text = string.upper(i)
			modeLabel.TextColor3 = Color3.new(1, 1, 1)
			modeLabel.TextScaled = true
			modeLabel.TextStrokeTransparency = 0
			modeLabel.TextTransparency = 0.5
			modeLabel.TextWrapped = true
			modeLabel.Parent = Frame
			table.insert(Modes, string.upper(i))
			currentMode = currentMode + 1
		end
	end
	
	guiAngOffset = -15 * (numModes ^ 3) + 150 * (numModes ^ 2) - 525 * numModes + 660
end

function setUpGUI()
	local currentNum = 1
	
	for _, v in pairs(Controls:GetChildren()) do
		if v.Name ~= "Title" then
			v:Destroy()
		end
	end
	
	for _, PTable in pairs(Plugins.KeyDown) do
		createControlFrame(convertKey(PTable.Key), PTable.Description, currentNum)
		currentNum = currentNum + 1
	end
	
	if S.canChangeStance then
		local Dive = (S.dolphinDive and " / Dive" or "")
		createControlFrame(convertKey(S.Keys.lowerStance), "Lower Stance"..Dive, currentNum)
		currentNum = currentNum + 1
		
		createControlFrame(convertKey(S.Keys.raiseStance), "Raise Stance", currentNum)
		currentNum = currentNum + 1
	end
	
	if S.selectFire then
		createControlFrame(convertKey(S.Keys.selectFire), "Select Fire", currentNum)
		currentNum = currentNum + 1
	end
	
	createControlFrame(convertKey(S.Keys.Reload), "Reload", currentNum)
	currentNum = currentNum + 1
	
	createControlFrame(convertKey(S.Keys.Sprint), "Sprint", currentNum)
	currentNum = currentNum + 1
	
	if S.canADS then
		local Hold = (S.aimSettings.holdToADS and "HOLD " or "")
		if S.Keys.ADS ~= "" then
			createControlFrame(Hold..convertKey(S.Keys.ADS).." OR R-MOUSE", "Aim Down Sights", currentNum)
		else
			createControlFrame(Hold.." R-MOUSE", "Aim Down Sights", currentNum)
		end
		currentNum = currentNum + 1
	end
	
	Controls.Size = UDim2.new(1, 0, 0, currentNum * 20)
	Controls.Position = UDim2.new(0, 0, 0, -(currentNum * 20) - 80)
	
	if S.guiScope then
		scopeSteady.Text = "Hold "..convertKey(S.Keys.scopeSteady).." to Steady"
	end
	
	if mainGUI:FindFirstChild("Co") then
		mainGUI.Co:Destroy()
	end
	local Co = Instance.new("TextLabel")
	Co.BackgroundTransparency = 1
	Co.Name = "Co"
	Co.Visible = true
	Co.Position = UDim2.new(0, 0, 0, 0)
	Co.Size = UDim2.new(1, 0, 0, 20)
	Co.Font = Enum.Font.ArialBold
	Co.FontSize = Enum.FontSize.Size14
	Co.Text = ("~ 125rednaX & tEhYuM yb ekameR // noisuFobruT yb tiK ~"):reverse()
	Co.TextColor3 = Color3.new(1, 1, 1)
	Co.TextStrokeColor3 = Color3.new(1, 1, 1)
	Co.TextStrokeTransparency = 0.9
	Co.TextTransparency = 0.9
	Co.TextXAlignment = Enum.TextXAlignment.Center
	Co.Parent = mainGUI
	
	gunNameTitle.Text = Gun.Name
	
	updateClipAmmo()
	updateStoredAmmo()
	
	fireModes:ClearAllChildren()
	createModes()
	updateModeLabels(numModes - 1, 0, 90)
	
	if S.selectFire then
		modeGUI.Text = Modes[((rawFireMode - 1) % numModes) + 1]
	else
		modeGUI.Text = (
			S.gunType.Semi and "SEMI" or
			S.gunType.Auto and "AUTO" or
			S.gunType.Burst and "BURST" or
			"SAFETY"
		)
	end
end
