function ConvertKey(z)if z==string.char(8)then return"\066\075\083\080\067\069"elseif z==string.char(9)then return"\084\065\066"elseif z==string.char(13)then return"\069\078\084\069\082"elseif z==string.char(17)then return"\085\080"elseif z==string.char(18)then return"\068\079\087\078"elseif z==string.char(19)then return"\082\073\071\072\084"elseif z==string.char(20)then return"\076\069\070\084"elseif z==string.char(22)then return"\072\079\077\069"elseif z==string.char(23)then return"\069\078\068"elseif z==string.char(27)then return"\070\050"elseif z==string.char(29)then return"\070\052"elseif z==string.char(30)then return"\070\053"elseif z==string.char(32)or z==" "then return"\070\055"elseif z==string.char(33)or z=="\033"then return"\070\056"elseif z==string.char(34)or z=="\""then return"\070\057"elseif z==string.char(35)or z=="\035"then return"\070\049\048"elseif z==string.char(37)or z=="\037"then return"\070\049\050"elseif z==string.char(47)or z=="\047"then return"\082-\083\072\073\070\084"elseif z==string.char(48)or z=="\048"then return"\076-\083\072\073\070\084"elseif z==string.char(49)or z=="\049"then return"\082-\067\084\082\076"elseif z==string.char(50)or z=="\050"then return"\076-\067\084\082\076"elseif z==string.char(51)or z=="\051"then return"\082-\065\076\084"elseif z==string.char(52)or z=="\052"then return"\076-\065\076\084"else return string.upper(z)end end function CreateControlFrame(z,h,U)local k=(Gui_Clone:WaitForChild("\072\085\068")):WaitForChild("\067\111\110\116\114\111\108\115")local V=Instance.new("\070\114\097\109\101")V.BackgroundTransparency=U%2==1 and.7 or 1 V.BorderSizePixel=0 V.Name="\067"..U V.Position=UDim2.new(0,0,0,U*20)V.Size=UDim2.new(1,0,0,20)local b=Instance.new("\084\101\120\116\076\097\098\101\108")b.BackgroundTransparency=1 b.Name="\075\101\121"b.Size=UDim2.new(0,45,1,0)b.Font=Enum.Font.ArialBold b.FontSize=Enum.FontSize.Size14 b.Text=z b.TextColor3=Color3.new(1,1,1)b.TextScaled=string.len(z)>5 b.TextWrapped=string.len(z)>5 b.Parent=V local g=Instance.new("\084\101\120\116\076\097\098\101\108")g.BackgroundTransparency=1 g.Name="\068\101\115\099"g.Position=UDim2.new(0,50,0,0)g.Size=UDim2.new(1,-50,1,0)g.Font=Enum.Font.ArialBold g.FontSize=Enum.FontSize.Size14 g.Text="- "..h g.TextColor3=Color3.new(1,1,1)g.TextXAlignment=Enum.TextXAlignment.Left g.Parent=V V.Parent=k end function SetUpGui()local z=Gui_Clone:WaitForChild("\072\085\068")local h=Gui_Clone:WaitForChild("\083\099\111\112\101")local U=z:WaitForChild("\071\114\101\110\097\100\101\115")local k=z:WaitForChild("\067\111\110\116\114\111\108\115")local V=1 if S.CanChangeStance then local z=S.DolphinDive and" \047 \068\105\118\101"or""CreateControlFrame(ConvertKey(S.LowerStanceKey),"\076\111\119\101\114 \083\116\097\110\099\101"..z,V)V=V+1 CreateControlFrame(ConvertKey(S.RaiseStanceKey),"\082\097\105\115\101 \083\116\097\110\099\101",V)V=V+1 end CreateControlFrame(ConvertKey(S.ReloadKey),"\082\101\108\111\097\100",V)V=V+1 if S.CanKnife then CreateControlFrame(ConvertKey(S.KnifeKey),"\075\110\105\102\101",V)V=V+1 end if S.Throwables then CreateControlFrame(ConvertKey(S.LethalGrenadeKey),"\084\104\114\111\119 \076\101\116\104\097\108",V)V=V+1 CreateControlFrame(ConvertKey(S.TacticalGrenadeKey),"\084\104\114\111\119 \084\097\099\116\105\099\097\108",V)V=V+1 else U.Visible=false z.Position=UDim2.new(1,-200,1,-100)z.Size=UDim2.new(0,175,0,50)end CreateControlFrame(ConvertKey(S.SprintKey),"\083\112\114\105\110\116",V)V=V+1 if S.ADSKey~=""then local z=S.HoldMouseOrKeyToADS and"\072\079\076\068 "or""CreateControlFrame(z..(ConvertKey(S.ADSKey).." \079\082 \082-\077\079\085\083\069"),"\065\105\109 \068\111\119\110 \083\105\103\104\116\115",V)V=V+1 end k.Size=UDim2.new(1,0,0,V*20)k.Position=UDim2.new(0,0,0,-(V*20)-80)if S.GuiScope then(h:WaitForChild("\073\109\103")).Image=S.GuiId;(h:WaitForChild("\083\116\101\097\100\121")).Text="\072\111\108\100 "..(ConvertKey(S.ScopeSteadyKey).." \116\111 \083\116\101\097\100\121")end if z:FindFirstChild("\067\111")then z.Co:Destroy()end local b=Instance.new("\084\101\120\116\076\097\098\101\108")b.BackgroundTransparency=1 b.Name="\067\111"b.Position=UDim2.new(0,0,1,5)b.Size=UDim2.new(1,0,0,20)b.Font=Enum.Font.ArialBold b.FontSize=Enum.FontSize.Size14 b.Text=("\110\111\105\115\117\070\111\098\114\117\084 \121\098 \100\101\116\112\105\114\099\115 \116\105\075 \110\117\071"):reverse()b.TextColor3=Color3.new(1,1,0)b.TextStrokeTransparency=0 b.TextXAlignment=Enum.TextXAlignment.Right b.Parent=z;(((z:WaitForChild("\071\114\101\110\097\100\101\115")):WaitForChild("\076\101\116\104\097\108\115")):WaitForChild("\073\099\111\110")).Image=LethalIcons[S.LethalGrenadeType];(((z:WaitForChild("\071\114\101\110\097\100\101\115")):WaitForChild("\084\097\099\116\105\099\097\108\115")):WaitForChild("\073\099\111\110")).Image=TacticalIcons[S.TacticalGrenadeType]end
--------------------[ GUI SETUP FUNCTION ]--------------------------------------------

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 Controls = Gui_Clone:WaitForChild("HUD"):WaitForChild("Controls")

	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)

	local K = Instance.new("TextLabel")
	K.BackgroundTransparency = 1
	K.Name = "Key"
	K.Size = UDim2.new(0, 45, 1, 0)
	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.Font = Enum.Font.ArialBold
	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 SetUpGui()
	local HUD = Gui_Clone:WaitForChild("HUD")
	local Scope = Gui_Clone:WaitForChild("Scope")
	local Grenades = HUD:WaitForChild("Grenades")
	local Controls = HUD:WaitForChild("Controls")
	local CurrentNum = 1

	if S.CanChangeStance then
		local Dive = (S.DolphinDive and " / Dive" or "")
		CreateControlFrame(ConvertKey(S.LowerStanceKey), "Lower Stance" .. Dive, CurrentNum)
		CurrentNum = CurrentNum + 1

		CreateControlFrame(ConvertKey(S.RaiseStanceKey), "Raise Stance", CurrentNum)
		CurrentNum = CurrentNum + 1
	end

	CreateControlFrame(ConvertKey(S.ReloadKey), "Reload", CurrentNum)
	CurrentNum = CurrentNum + 1

	if S.CanKnife then
		CreateControlFrame(ConvertKey(S.KnifeKey), "Knife", CurrentNum)
		CurrentNum = CurrentNum + 1
	end

	if S.Throwables then
		CreateControlFrame(ConvertKey(S.LethalGrenadeKey), "Throw Lethal", CurrentNum)
		CurrentNum = CurrentNum + 1

		CreateControlFrame(ConvertKey(S.TacticalGrenadeKey), "Throw Tactical", CurrentNum)
		CurrentNum = CurrentNum + 1
	else
		Grenades.Visible = false
		HUD.Position = UDim2.new(1, -200, 1, -100)
		HUD.Size = UDim2.new(0, 175, 0, 50)
	end

	CreateControlFrame(ConvertKey(S.SprintKey), "Sprint", CurrentNum)
	CurrentNum = CurrentNum + 1

	if S.ADSKey ~= "" then
		local Hold = (S.HoldMouseOrKeyToADS and "HOLD " or "")
		CreateControlFrame(Hold .. ConvertKey(S.ADSKey) .. " OR R-MOUSE", "Aim Down Sights", CurrentNum)
		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
		Scope:WaitForChild("Img").Image = S.GuiId
		Scope:WaitForChild("Steady").Text = "Hold " .. ConvertKey(S.ScopeSteadyKey) .. " to Steady"
	end

	if HUD:FindFirstChild("Co") then
		HUD.Co:Destroy()
	end
	local Co = Instance.new("TextLabel")
	Co.BackgroundTransparency = 1
	Co.Name = "Co"
	Co.Position = UDim2.new(0, 0, 1, 5)
	Co.Size = UDim2.new(1, 0, 0, 20)
	Co.Font = Enum.Font.ArialBold
	Co.FontSize = Enum.FontSize.Size14
	Co.Text = ("noisuFobruT yb detpircs tiK nuG"):reverse()
	Co.TextColor3 = Color3.new(1, 1, 0)
	Co.TextStrokeTransparency = 0
	Co.TextXAlignment = Enum.TextXAlignment.Right
	Co.Parent = HUD

	HUD:WaitForChild("Grenades"):WaitForChild("Lethals"):WaitForChild("Icon").Image = LethalIcons[S.LethalGrenadeType]
	HUD:WaitForChild("Grenades"):WaitForChild("Tacticals"):WaitForChild("Icon").Image =
		TacticalIcons[S.TacticalGrenadeType]
end
