OPEN SOURCE BY TRX CLAN
Key Required

OPEN SOURCE BY TRX CLAN

ArmsOfSolitaire BETATEAM_TRXTEAM_TRX 812 views 278 executesUpdated Jan 13, 2026
5.0/ 5(1 votes)
10100% Positive
Lua Script•2317 lines (70458 chars)
-- made by aaltaccount0891 in discord
-- im always happy to make custom scripts just contact me
-- if your one of the staff of the game i made cheats for contact me i just wanna make friends :)
-- this is so easy to patch lol

-- v2 is in works and will be the most powerfull cheat 

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")
local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
local Camera = Workspace.CurrentCamera
local LocalPlayer = Players.LocalPlayer

local settings = {
	esp = false,
	noclip = false,
	teamCheck = true,
	fogRemover = true,
	hitbox = false,
	infjump = false,
	speed = false,
	triggerbot = false,
	aimbot = false,
	grenadeHitbox = false,
	autoFollowEnemy = false,
	invisibility = false,
	freeCam = false,
	tpEnemiesInFront = false,
	hitboxScale = false,
	fullBright = false,
	statsHUD = false,
	safeWalk = false,
	aimbotSpam = false,
	aimbotHoldClick = false,
	healthLock = false,
	hitboxScaleSize = 100,
	hitboxSize = 10,
	grenadeHitboxSize = 50,
	jumpPower = 50,
	speedMultiplier = 2,
	triggerbotDelay = 0.3,
	maxDistance = 300,
	aimbotFOV = 100,
	tracers = false,
	autoTPKill = false,
	autoTPDelay = 0.5,
	anticheatBypass = false,
	keybinds = {
		esp = Enum.KeyCode.F1,
		noclip = Enum.KeyCode.F2,
		teamCheck = Enum.KeyCode.F3,
		fogRemover = Enum.KeyCode.F4,
		hitbox = Enum.KeyCode.F5,
		infjump = Enum.KeyCode.F6,
		speed = Enum.KeyCode.F7,
		triggerbot = Enum.KeyCode.F8,
		aimbot = Enum.KeyCode.F9,
		tracers = Enum.KeyCode.F10,
		autoTPKill = Enum.KeyCode.T
	}
}

local state = {
	noclipConnection = nil,
	speedConnection = nil,
	hitboxConnection = nil,
	triggerbotConnection = nil,
	aimbotConnection = nil,
	grenadeHitboxConnection = nil,
	autoFollowConnection = nil,
	currentFollowTarget = nil,
	lastTeleport = 0,
	freeCamConnection = nil,
	originalCamSubject = nil,
	tpEnemiesConnection = nil,
	hitboxScaleConnection = nil,
	fullBrightConnection = nil,
	originalLightingSettings = {},
	statsHUDConnection = nil,
	safeWalkConnection = nil,
	safeWalkBlocks = {},
	healthLockConnection = nil,
	isHoldingClick = false,
	hudElements = {},
	originalHitboxSizes = {}, -- [Part] = Vector3
	fovCircle = nil,
	espObjects = {},
	tracerDrawings = {}, -- [Player] = Drawing.Line
	autoTPKillConnection = nil,
	lastAutoTP = 0,
	hitboxParts = {},
	changingKeybind = nil,
	canJump = true,
	lastShot = 0,
	playerCharacters = {},
	cachedParts = {}, -- [Player] = {Head = Part, Body = {Part, Part, ...}}
	toggleUpdaters = {} -- Store UI update functions for each setting
}

-- Feature Functions Forward Declarations
local toggleESP, toggleNoclip, toggleTeamCheck, toggleFogRemover, toggleHitbox, toggleInfJump, toggleSpeed, toggleTriggerbot, toggleAimbot, toggleTracers, toggleAutoTPKill

-- UI Library
local UI = {}
local colors = {
	background = Color3.fromRGB(12, 12, 12),
	foreground = Color3.fromRGB(20, 20, 20),
	accent = Color3.fromRGB(255, 255, 255),
	text = Color3.fromRGB(245, 245, 245),
	textDim = Color3.fromRGB(160, 160, 160),
	border = Color3.fromRGB(35, 35, 35),
	control = Color3.fromRGB(28, 28, 28)
}

function UI.MakeDraggable(frame, handle)
	handle = handle or frame
	local dragging, dragInput, dragStart, startPos
	
	local function update(input)
		local delta = input.Position - dragStart
		frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
	end
	
	handle.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging = true
			dragStart = input.Position
			startPos = frame.Position
			
			input.Changed:Connect(function()
				if input.UserInputState == Enum.UserInputState.End then
					dragging = false
				end
			end)
		end
	end)
	
	handle.InputChanged:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
			dragInput = input
		end
	end)
	
	UserInputService.InputChanged:Connect(function(input)
		if input == dragInput and dragging then
			update(input)
		end
	end)
end

function UI.CreateWindow()
	local sg = Instance.new("ScreenGui")
	sg.Name = "AceHelperPremium"
	sg.ResetOnSpawn = false
	sg.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
	sg.IgnoreGuiInset = true
	
	local main = Instance.new("Frame")
	main.Name = "Main"
	main.Size = UDim2.new(0, 520, 0, 360)
	main.Position = UDim2.new(0.5, -260, 0.5, -180)
	main.BackgroundColor3 = colors.background
	main.BorderSizePixel = 0
	main.Parent = sg
	
	local uicorner = Instance.new("UICorner")
	uicorner.CornerRadius = UDim.new(0, 10)
	uicorner.Parent = main
	
	local stroke = Instance.new("UIStroke")
	stroke.Color = colors.border
	stroke.Thickness = 1
	stroke.Parent = main
	
	-- Top Bar
	local topbar = Instance.new("Frame")
	topbar.Name = "TopBar"
	topbar.Size = UDim2.new(1, 0, 0, 45)
	topbar.BackgroundColor3 = colors.background
	topbar.BorderSizePixel = 0
	topbar.Parent = main
	
	local topCorner = Instance.new("UICorner")
	topCorner.CornerRadius = UDim.new(0, 10)
	topCorner.Parent = topbar
	
	local title = Instance.new("TextLabel")
	title.Text = "ACE HELPER <font color='#FFFFFF'>PREMIUM</font>"
	title.RichText = true
	title.Font = Enum.Font.GothamBold
	title.TextSize = 16
	title.TextColor3 = colors.textDim
	title.Size = UDim2.new(0, 200, 1, 0)
	title.Position = UDim2.new(0, 20, 0, 0)
	title.BackgroundTransparency = 1
	title.TextXAlignment = Enum.TextXAlignment.Left
	title.Parent = topbar
	
	UI.MakeDraggable(main, topbar)
	
	-- Separator
	local sep = Instance.new("Frame")
	sep.Size = UDim2.new(1, -40, 0, 1)
	sep.Position = UDim2.new(0, 20, 1, -1)
	sep.BackgroundColor3 = colors.border
	sep.BorderSizePixel = 0
	sep.Parent = topbar
	
	-- Content Area
	local content = Instance.new("Frame")
	content.Name = "Content"
	content.Size = UDim2.new(1, 0, 1, -45)
	content.Position = UDim2.new(0, 0, 0, 45)
	content.BackgroundTransparency = 1
	content.Parent = main
	
	-- Navigation
	local nav = Instance.new("Frame")
	nav.Name = "Navigation"
	nav.Size = UDim2.new(0, 130, 1, -20)
	nav.Position = UDim2.new(0, 15, 0, 10)
	nav.BackgroundTransparency = 1
	nav.Parent = content
	
	local navList = Instance.new("UIListLayout")
	navList.Padding = UDim.new(0, 6)
	navList.SortOrder = Enum.SortOrder.LayoutOrder
	navList.Parent = nav
	
	local indicator = Instance.new("Frame")
	indicator.Name = "Indicator"
	indicator.Size = UDim2.new(0, 2, 0, 20)
	indicator.Position = UDim2.new(0, -5, 0, 0)
	indicator.BackgroundColor3 = colors.accent
	indicator.BorderSizePixel = 0
	indicator.Visible = true
	indicator.Parent = nav
	
	local indCorner = Instance.new("UICorner")
	indCorner.CornerRadius = UDim.new(1, 0)
	indCorner.Parent = indicator
	
	-- Pages Container
	local pages = Instance.new("Frame")
	pages.Name = "Pages"
	pages.Size = UDim2.new(1, -165, 1, -20)
	pages.Position = UDim2.new(0, 150, 0, 10)
	pages.BackgroundColor3 = colors.foreground
	pages.BorderSizePixel = 0
	pages.Parent = content
	
	local pagesCorner = Instance.new("UICorner")
	pagesCorner.CornerRadius = UDim.new(0, 8)
	pagesCorner.Parent = pages
	
	local pagesStroke = Instance.new("UIStroke")
	pagesStroke.Color = colors.border
	pagesStroke.Thickness = 1
	pagesStroke.Parent = pages
	
	return sg, nav, pages, indicator
end

local function createTabButton(ui, nav, pages, indicator, name, icon)
	local pageFrame = Instance.new("ScrollingFrame")
	pageFrame.Name = name .. "Page"
	pageFrame.Size = UDim2.new(1, 0, 1, 0)
	pageFrame.BackgroundTransparency = 1
	pageFrame.BorderSizePixel = 0
	pageFrame.ScrollBarThickness = 2
	pageFrame.Visible = false
	pageFrame.Parent = pages
	
	local layout = Instance.new("UIListLayout")
	layout.Padding = UDim.new(0, 8)
	layout.SortOrder = Enum.SortOrder.LayoutOrder
	layout.Parent = pageFrame
	
	layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
		pageFrame.CanvasSize = UDim2.new(0, 0, 0, layout.AbsoluteContentSize.Y + 20)
	end)
	
	local padding = Instance.new("UIPadding")
	padding.PaddingTop = UDim.new(0, 10)
	padding.PaddingLeft = UDim.new(0, 10)
	padding.PaddingRight = UDim.new(0, 10)
	padding.PaddingBottom = UDim.new(0, 10)
	padding.Parent = pageFrame
	
	local btn = Instance.new("TextButton")
	btn.Name = name .. "Btn"
	btn.Size = UDim2.new(1, 0, 0, 32)
	btn.BackgroundTransparency = 1
	btn.Text = name
	btn.Font = Enum.Font.GothamMedium
	btn.TextSize = 14
	btn.TextColor3 = colors.textDim
	btn.AutoButtonColor = false
	btn.TextXAlignment = Enum.TextXAlignment.Left
	btn.Parent = nav
	
	local btnPadding = Instance.new("UIPadding")
	btnPadding.PaddingLeft = UDim.new(0, 10)
	btnPadding.Parent = btn

	btn.MouseEnter:Connect(function()
		if not pageFrame.Visible then
			TweenService:Create(btn, TweenInfo.new(0.2), {TextColor3 = colors.text}):Play()
		end
	end)

	btn.MouseLeave:Connect(function()
		if not pageFrame.Visible then
			TweenService:Create(btn, TweenInfo.new(0.2), {TextColor3 = colors.textDim}):Play()
		end
	end)
	
	btn.MouseButton1Click:Connect(function()
		for _, child in ipairs(pages:GetChildren()) do
			if child:IsA("ScrollingFrame") then child.Visible = false end
		end
		pageFrame.Visible = true
		
		for _, child in ipairs(nav:GetChildren()) do
			if child:IsA("TextButton") then
				TweenService:Create(child, TweenInfo.new(0.3), {TextColor3 = colors.textDim}):Play()
			end
		end
		
		TweenService:Create(btn, TweenInfo.new(0.3), {TextColor3 = colors.text}):Play()
		TweenService:Create(indicator, TweenInfo.new(0.4, Enum.EasingStyle.Quint), {
			Position = UDim2.new(0, -5, 0, btn.Position.Y.Offset + 6),
			Size = UDim2.new(0, 2, 0, 20)
		}):Play()
	end)
	
	return pageFrame, btn
end

local function createToggleUI(page, text, settingKey, callback, existingKeyEnum)
	local frame = Instance.new("Frame")
	frame.Size = UDim2.new(1, 0, 0, 36)
	frame.BackgroundTransparency = 1
	frame.Parent = page
	
	local label = Instance.new("TextLabel")
	label.Text = text
	label.Font = Enum.Font.Gotham
	label.TextSize = 13
	label.TextColor3 = colors.textDim
	label.TextXAlignment = Enum.TextXAlignment.Left
	label.Size = UDim2.new(1, -90, 1, 0)
	label.Position = UDim2.new(0, 0, 0, 0)
	label.BackgroundTransparency = 1
	label.Parent = frame
	
	local toggleBtn = Instance.new("TextButton")
	toggleBtn.Size = UDim2.new(0, 34, 0, 18)
	toggleBtn.Position = UDim2.new(1, -34, 0.5, -9)
	toggleBtn.BackgroundColor3 = colors.control
	toggleBtn.Text = ""
	toggleBtn.AutoButtonColor = false
	toggleBtn.Parent = frame
	
	local toggleCorner = Instance.new("UICorner")
	toggleCorner.CornerRadius = UDim.new(1, 0)
	toggleCorner.Parent = toggleBtn
	
	local toggleStroke = Instance.new("UIStroke")
	toggleStroke.Color = colors.border
	toggleStroke.Thickness = 1
	toggleStroke.Parent = toggleBtn
	
	local circle = Instance.new("Frame")
	circle.Size = UDim2.new(0, 12, 0, 12)
	circle.Position = UDim2.new(0, 3, 0.5, -6)
	circle.BackgroundColor3 = colors.textDim
	circle.Parent = toggleBtn
	
	local circleCorner = Instance.new("UICorner")
	circleCorner.CornerRadius = UDim.new(1, 0)
	circleCorner.Parent = circle
	
	-- Keybind
	local bindBtn = Instance.new("TextButton")
	bindBtn.Size = UDim2.new(0, 30, 0, 18)
	bindBtn.Position = UDim2.new(1, -75, 0.5, -9)
	bindBtn.BackgroundColor3 = colors.control
	bindBtn.Text = existingKeyEnum and existingKeyEnum.Name:gsub("^%l", string.upper):sub(1,3) or "NONE"
	bindBtn.Font = Enum.Font.Gotham
	bindBtn.TextSize = 10
	bindBtn.TextColor3 = colors.textDim
	bindBtn.AutoButtonColor = false
	bindBtn.Parent = frame
	
	local bindCorner = Instance.new("UICorner")
	bindCorner.CornerRadius = UDim.new(0, 4)
	bindCorner.Parent = bindBtn
	
	local bindStroke = Instance.new("UIStroke")
	bindStroke.Color = colors.border
	bindStroke.Thickness = 1
	bindStroke.Parent = bindBtn
	
	local function update(enabled)
		if enabled then
			TweenService:Create(toggleBtn, TweenInfo.new(0.3, Enum.EasingStyle.Quint), {BackgroundColor3 = colors.accent}):Play()
			TweenService:Create(circle, TweenInfo.new(0.3, Enum.EasingStyle.Quint), {Position = UDim2.new(1, -15, 0.5, -6), BackgroundColor3 = colors.background}):Play()
			TweenService:Create(label, TweenInfo.new(0.3), {TextColor3 = colors.text}):Play()
		else
			TweenService:Create(toggleBtn, TweenInfo.new(0.3, Enum.EasingStyle.Quint), {BackgroundColor3 = colors.control}):Play()
			TweenService:Create(circle, TweenInfo.new(0.3, Enum.EasingStyle.Quint), {Position = UDim2.new(0, 3, 0.5, -6), BackgroundColor3 = colors.textDim}):Play()
			TweenService:Create(label, TweenInfo.new(0.3), {TextColor3 = colors.textDim}):Play()
		end
	end
	
	toggleBtn.MouseEnter:Connect(function()
		TweenService:Create(toggleStroke, TweenInfo.new(0.2), {Color = colors.textDim}):Play()
	end)
	toggleBtn.MouseLeave:Connect(function()
		TweenService:Create(toggleStroke, TweenInfo.new(0.2), {Color = colors.border}):Play()
	end)
	
	toggleBtn.MouseButton1Click:Connect(function()
		callback()
		update(settings[settingKey])
	end)
	
	bindBtn.MouseButton1Click:Connect(function()
		bindBtn.Text = "..."
		bindBtn.TextColor3 = colors.accent
		state.changingKeybind = {
			button = bindBtn,
			setting = settingKey,
			updateUI = function(key) 
				bindBtn.Text = key.Name:gsub("^%l", string.upper):sub(1,3)
				bindBtn.TextColor3 = colors.textDim
			end
		}
	end)
	
	update(settings[settingKey])
	state.toggleUpdaters[settingKey] = update
	return frame, update
end

local function createSliderUI(page, text, min, max, settingKey)
	local frame = Instance.new("Frame")
	frame.Size = UDim2.new(1, 0, 0, 45)
	frame.BackgroundTransparency = 1
	frame.Parent = page
	
	local label = Instance.new("TextLabel")
	label.Text = text
	label.Font = Enum.Font.Gotham
	label.TextSize = 13
	label.TextColor3 = colors.textDim
	label.TextXAlignment = Enum.TextXAlignment.Left
	label.Size = UDim2.new(1, -60, 0, 20)
	label.Position = UDim2.new(0, 0, 0, 0)
	label.BackgroundTransparency = 1
	label.Parent = frame
	
	local valueLabel = Instance.new("TextBox")
	valueLabel.Text = tostring(settings[settingKey])
	valueLabel.Font = Enum.Font.GothamMedium
	valueLabel.TextSize = 13
	valueLabel.TextColor3 = colors.accent
	valueLabel.TextXAlignment = Enum.TextXAlignment.Right
	valueLabel.Size = UDim2.new(0, 50, 0, 20)
	valueLabel.Position = UDim2.new(1, -50, 0, 0)
	valueLabel.BackgroundTransparency = 1
	valueLabel.Parent = frame
	
	local sliderBg = Instance.new("Frame")
	sliderBg.Size = UDim2.new(1, 0, 0, 4)
	sliderBg.Position = UDim2.new(0, 0, 0, 30)
	sliderBg.BackgroundColor3 = colors.control
	sliderBg.Parent = frame
	
	local sliderCorner = Instance.new("UICorner")
	sliderCorner.CornerRadius = UDim.new(1, 0)
	sliderCorner.Parent = sliderBg
	
	local sliderStroke = Instance.new("UIStroke")
	sliderStroke.Color = colors.border
	sliderStroke.Thickness = 1
	sliderStroke.Parent = sliderBg
	
	local sliderFill = Instance.new("Frame")
	local defaultPercent = (settings[settingKey] - min) / (max - min)
	sliderFill.Size = UDim2.new(defaultPercent, 0, 1, 0)
	sliderFill.BackgroundColor3 = colors.accent
	sliderFill.Parent = sliderBg
	
	local fillCorner = Instance.new("UICorner")
	fillCorner.CornerRadius = UDim.new(1, 0)
	fillCorner.Parent = sliderFill
	
	local triggerBtn = Instance.new("TextButton")
	triggerBtn.Size = UDim2.new(1, 0, 1, 0)
	triggerBtn.BackgroundTransparency = 1
	triggerBtn.Text = ""
	triggerBtn.AutoButtonColor = false
	triggerBtn.Parent = sliderBg
	
	local dragging = false
	
	local function update(input)
		local relativeX = input.Position.X - sliderBg.AbsolutePosition.X
		local percent = math.clamp(relativeX / sliderBg.AbsoluteSize.X, 0, 1)
		local value = min + (max - min) * percent
		
		if max - min > 100 then
			value = math.floor(value)
		else
			value = math.floor(value * 100) / 100
		end
		
		settings[settingKey] = value
		valueLabel.Text = tostring(value)
		TweenService:Create(sliderFill, TweenInfo.new(0.2, Enum.EasingStyle.Quint), {Size = UDim2.new(percent, 0, 1, 0)}):Play()
	end
	
	triggerBtn.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			dragging = true
			update(input)
			TweenService:Create(sliderStroke, TweenInfo.new(0.2), {Color = colors.accent}):Play()
		end
	end)
	
	triggerBtn.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			dragging = false
			TweenService:Create(sliderStroke, TweenInfo.new(0.2), {Color = colors.border}):Play()
		end
	end)
	
	UserInputService.InputChanged:Connect(function(input)
		if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
			update(input)
		end
	end)
	
	valueLabel.FocusLost:Connect(function()
		local n = tonumber(valueLabel.Text)
		if n then
			n = math.clamp(n, min, max)
			settings[settingKey] = n
			valueLabel.Text = tostring(n)
			local percent = (n - min) / (max - min)
			TweenService:Create(sliderFill, TweenInfo.new(0.2, Enum.EasingStyle.Quint), {Size = UDim2.new(percent, 0, 1, 0)}):Play()
		else
			valueLabel.Text = tostring(settings[settingKey])
		end
	end)
end

local function createButtonUI(page, text, callback)
	local frame = Instance.new("Frame")
	frame.Size = UDim2.new(1, 0, 0, 36)
	frame.BackgroundTransparency = 1
	frame.Parent = page
	
	local btn = Instance.new("TextButton")
	btn.Size = UDim2.new(1, 0, 1, 0)
	btn.BackgroundColor3 = colors.accent
	btn.Text = text:upper()
	btn.Font = Enum.Font.GothamBold
	btn.TextSize = 13
	btn.TextColor3 = colors.background
	btn.AutoButtonColor = false
	btn.Parent = frame
	
	local btnCorner = Instance.new("UICorner")
	btnCorner.CornerRadius = UDim.new(0, 4)
	btnCorner.Parent = btn
	
	btn.MouseEnter:Connect(function()
		TweenService:Create(btn, TweenInfo.new(0.2), {BackgroundColor3 = Color3.new(0.8, 0.8, 0.8)}):Play()
	end)
	btn.MouseLeave:Connect(function()
		TweenService:Create(btn, TweenInfo.new(0.2), {BackgroundColor3 = colors.accent}):Play()
	end)
	
	btn.MouseButton1Click:Connect(callback)
	
	return frame
end

local function createWarningUI(page, text)
	local frame = Instance.new("Frame")
	frame.Size = UDim2.new(1, 0, 0, 36)
	frame.BackgroundColor3 = colors.background
	frame.BorderSizePixel = 0
	frame.Parent = page
	
	local corner = Instance.new("UICorner")
	corner.CornerRadius = UDim.new(0, 4)
	corner.Parent = frame
	
	local stroke = Instance.new("UIStroke")
	stroke.Color = colors.border
	stroke.Thickness = 1
	stroke.Parent = frame
	
	local label = Instance.new("TextLabel")
	label.Size = UDim2.new(1, -20, 1, 0)
	label.Position = UDim2.new(0, 10, 0, 0)
	label.BackgroundTransparency = 1
	label.Text = "⚠️ " .. text:upper()
	label.Font = Enum.Font.GothamBold
	label.TextSize = 10
	label.TextColor3 = colors.textDim
	label.TextXAlignment = Enum.TextXAlignment.Center
	label.Parent = frame
	
	return frame
end

-- Init UI
local gui, nav, pages, indicator = UI.CreateWindow()
local visualsPage, visualsBtn = createTabButton(gui, nav, pages, indicator, "Visuals", "")
local combatPage, combatBtn = createTabButton(gui, nav, pages, indicator, "Combat", "")
local movementPage, movementBtn = createTabButton(gui, nav, pages, indicator, "Movement", "")
local experimentalPage, experimentalBtn = createTabButton(gui, nav, pages, indicator, "Experimental", "")

-- Set initial indicator position
task.spawn(function()
	task.wait(0.1)
	indicator.Position = UDim2.new(0, -5, 0, visualsBtn.Position.Y.Offset + 6)
end)

-- Feature Logic (Original Logic Preserved)
local function disableFog()
	Lighting.FogEnd = 1e6
	Lighting.FogStart = 0
	Lighting.FogColor = Color3.new(1, 1, 1)
end

local function enableFog()
	Lighting.FogEnd = 500
	Lighting.FogStart = 0
end

local function enableFullBright()
	-- Store original settings
	if not state.originalLightingSettings.Ambient then
		state.originalLightingSettings.Ambient = Lighting.Ambient
		state.originalLightingSettings.Brightness = Lighting.Brightness
		state.originalLightingSettings.OutdoorAmbient = Lighting.OutdoorAmbient
		state.originalLightingSettings.ColorShift_Top = Lighting.ColorShift_Top
		state.originalLightingSettings.ColorShift_Bottom = Lighting.ColorShift_Bottom
	end
	
	-- Apply full bright
	Lighting.Ambient = Color3.new(1, 1, 1)
	Lighting.Brightness = 2
	Lighting.OutdoorAmbient = Color3.new(1, 1, 1)
	Lighting.ColorShift_Top = Color3.new(0, 0, 0)
	Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
end

local function disableFullBright()
	-- Restore original settings
	if state.originalLightingSettings.Ambient then
		Lighting.Ambient = state.originalLightingSettings.Ambient
		Lighting.Brightness = state.originalLightingSettings.Brightness
		Lighting.OutdoorAmbient = state.originalLightingSettings.OutdoorAmbient
		Lighting.ColorShift_Top = state.originalLightingSettings.ColorShift_Top
		Lighting.ColorShift_Bottom = state.originalLightingSettings.ColorShift_Bottom
		state.originalLightingSettings = {}
	end
end

local function createStatsHUD()
	-- Create top left stats (Player count + FPS)
	local leftLabel = Instance.new("TextLabel")
	leftLabel.Name = "StatsHUD_Left"
	leftLabel.Position = UDim2.new(0, 10, 0, 10)
	leftLabel.Size = UDim2.new(0, 200, 0, 100)
	leftLabel.BackgroundTransparency = 1
	leftLabel.Font = Enum.Font.GothamBold
	leftLabel.TextSize = 14
	leftLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	leftLabel.TextXAlignment = Enum.TextXAlignment.Left
	leftLabel.TextYAlignment = Enum.TextYAlignment.Top
	leftLabel.TextStrokeTransparency = 0.5
	leftLabel.Parent = gui
	
	-- Create top right stats (Active cheats)
	local rightLabel = Instance.new("TextLabel")
	rightLabel.Name = "StatsHUD_Right"
	rightLabel.Position = UDim2.new(1, -210, 0, 10)
	rightLabel.Size = UDim2.new(0, 200, 0, 300)
	rightLabel.BackgroundTransparency = 1
	rightLabel.Font = Enum.Font.GothamBold
	rightLabel.TextSize = 14
	rightLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	rightLabel.TextXAlignment = Enum.TextXAlignment.Right
	rightLabel.TextYAlignment = Enum.TextYAlignment.Top
	rightLabel.TextStrokeTransparency = 0.5
	rightLabel.Parent = gui
	
	state.hudElements.leftLabel = leftLabel
	state.hudElements.rightLabel = rightLabel
end

local function removeStatsHUD()
	if state.hudElements.leftLabel then
		state.hudElements.leftLabel:Destroy()
		state.hudElements.leftLabel = nil
	end
	if state.hudElements.rightLabel then
		state.hudElements.rightLabel:Destroy()
		state.hudElements.rightLabel = nil
	end
end

local function updateStatsHUD()
	if not settings.statsHUD or not state.hudElements.leftLabel then return end
	
	-- Update FPS
	local fps = math.floor(1 / RunService.RenderStepped:Wait())
	
	-- Count players per team
	local blueCount = 0
	local greenCount = 0
	
	local gameFolder = Workspace:FindFirstChild("Game")
	if gameFolder then
		local playersFolder = gameFolder:FindFirstChild("Players")
		if playersFolder then
			local blueTeam = playersFolder:FindFirstChild("Blue")
			local greenTeam = playersFolder:FindFirstChild("Green")
			
			if blueTeam then
				for _, playerFolder in ipairs(blueTeam:GetChildren()) do
					if playerFolder:IsA("Folder") then
						blueCount = blueCount + 1
					end
				end
			end
			
			if greenTeam then
				for _, playerFolder in ipairs(greenTeam:GetChildren()) do
					if playerFolder:IsA("Folder") then
						greenCount = greenCount + 1
					end
				end
			end
		end
	end
	
	-- Update left label
	state.hudElements.leftLabel.Text = string.format("FPS: %d\nBlue Team: %d\nGreen Team: %d", fps, blueCount, greenCount)
	
	-- Update right label with active features
	local activeFeatures = {}
	if settings.esp then table.insert(activeFeatures, "ESP") end
	if settings.aimbot then table.insert(activeFeatures, "Aimbot") end
	if settings.triggerbot then table.insert(activeFeatures, "Triggerbot") end
	if settings.noclip then table.insert(activeFeatures, "Noclip") end
	if settings.speed then table.insert(activeFeatures, "Speed") end
	if settings.infjump then table.insert(activeFeatures, "Inf Jump") end
	if settings.hitbox then table.insert(activeFeatures, "Hitbox Expand") end
	if settings.fogRemover then table.insert(activeFeatures, "Fog Remover") end
	if settings.fullBright then table.insert(activeFeatures, "Full Bright") end
	if settings.grenadeHitbox then table.insert(activeFeatures, "Grenade Hitbox") end
	if settings.autoFollowEnemy then table.insert(activeFeatures, "Auto-Follow") end
	if settings.invisibility then table.insert(activeFeatures, "Invisibility") end
	if settings.freeCam then table.insert(activeFeatures, "Free Cam") end
	if settings.tpEnemiesInFront then table.insert(activeFeatures, "TP Enemies") end
	if settings.hitboxScale then table.insert(activeFeatures, "Hitbox Scale") end
	
	if #activeFeatures > 0 then
		state.hudElements.rightLabel.Text = "Active:\n" .. table.concat(activeFeatures, "\n")
	else
		state.hudElements.rightLabel.Text = "Active:\nNone"
	end
end


local function getCenterPart(character: Model)
	if not character then return nil end
	return character:FindFirstChild("HumanoidRootPart") 
		or character:FindFirstChild("Torso") 
		or character:FindFirstChild("UpperTorso")
		or character:FindFirstChildWhichIsA("BasePart")
end

local function isSameTeam(a: Player, b: Player): boolean
	if not settings.teamCheck then return false end
	if a.Team and b.Team then
		return a.Team == b.Team
	end
	return false
end

local function updatePlayerCache()
	state.playerCharacters = {}
	state.cachedParts = {}
	for _, p in ipairs(Players:GetPlayers()) do
		if p ~= LocalPlayer and p.Character then
			state.playerCharacters[p.Character] = p
			
			local parts = {Head = nil, Body = {}}
			for _, part in ipairs(p.Character:GetDescendants()) do
				if part:IsA("BasePart") then
					local name = part.Name:lower()
					if name:match("head") then
						parts.Head = part
					elseif name:match("torso") or name:match("chest") or name:match("upper") or name:match("root") then
						table.insert(parts.Body, part)
					end
				end
			end
			state.cachedParts[p] = parts
		end
	end
end

local function getRandomEnemy()
	local enemies = {}
	for _, p in ipairs(Players:GetPlayers()) do
		if p ~= LocalPlayer and p.Character and not isSameTeam(LocalPlayer, p) then
			local gameFolder = Workspace:FindFirstChild("Game")
			if gameFolder then
				local playersFolder = gameFolder:FindFirstChild("Players")
				if playersFolder then
					for _, teamName in ipairs({"Blue", "Green"}) do
						local teamFolder = playersFolder:FindFirstChild(teamName)
						if teamFolder then
							local playerFolder = teamFolder:FindFirstChild(p.Name)
							if playerFolder then
								local healthValue = playerFolder:FindFirstChild("Health")
								if healthValue and (healthValue:IsA("NumberValue") or healthValue:IsA("IntValue")) then
									if healthValue.Value > 0 then
										table.insert(enemies, p)
									end
								end
								break
							end
						end
					end
				end
			end
		end
	end
	if #enemies > 0 then
		return enemies[math.random(1, #enemies)]
	end
	return nil
end

local function autoFollowLoop()
	if not settings.autoFollowEnemy then return end
	local needNewTarget = false
	if not state.currentFollowTarget or not state.currentFollowTarget.Character then
		needNewTarget = true
	else
		local gameFolder = Workspace:FindFirstChild("Game")
		if gameFolder then
			local playersFolder = gameFolder:FindFirstChild("Players")
			if playersFolder then
				local isAlive = false
				for _, teamName in ipairs({"Blue", "Green"}) do
					local teamFolder = playersFolder:FindFirstChild(teamName)
					if teamFolder then
						local playerFolder = teamFolder:FindFirstChild(state.currentFollowTarget.Name)
						if playerFolder then
							local healthValue = playerFolder:FindFirstChild("Health")
							if healthValue and (healthValue:IsA("NumberValue") or healthValue:IsA("IntValue")) then
								if healthValue.Value > 0 then
									isAlive = true
								end
							end
							break
						end
					end
				end
				if not isAlive then
					needNewTarget = true
				end
			end
		end
	end
	if needNewTarget then
		state.currentFollowTarget = getRandomEnemy()
		if state.currentFollowTarget then
			print("Following: " .. state.currentFollowTarget.Name)
		end
	end
	if state.currentFollowTarget and state.currentFollowTarget.Character then
		local now = tick()
		-- Only teleport every 0.5 seconds to avoid anti-cheat
		if now - state.lastTeleport >= 0.5 then
			local targetHRP = state.currentFollowTarget.Character:FindFirstChild("HumanoidRootPart")
			local myChar = LocalPlayer.Character
			if targetHRP and myChar then
				local myHRP = myChar:FindFirstChild("HumanoidRootPart")
				if myHRP then
					-- Add randomization to position (behind + slight offset)
					local randomX = math.random(-2, 2)
					local randomZ = math.random(2, 4)
					local behindPosition = targetHRP.CFrame * CFrame.new(randomX, 0, randomZ)
					myHRP.CFrame = behindPosition
					state.lastTeleport = now
				end
			end
		end
	end
end

local function applyESP(player: Player)
	local function addHighlight(character: Model)
		if not settings.esp then return end
		if character:FindFirstChild("ESP_Highlight") then return end
		
		local h = Instance.new("Highlight")
		h.Name = "ESP_Highlight"
		h.Adornee = character
		h.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
		h.FillTransparency = 0.7
		h.OutlineTransparency = 0
		h.OutlineColor = Color3.fromRGB(255, 255, 255)
		h.FillColor = isSameTeam(LocalPlayer, player) 
			and Color3.fromRGB(255, 255, 255) 
			or Color3.fromRGB(255, 0, 0)
		h.Parent = character
		
		state.espObjects[player] = h
	end
	
	player.CharacterAdded:Connect(function(char)
		task.wait(0.5)
		addHighlight(char)
	end)
	
	if player.Character then
		addHighlight(player.Character)
	end
end

local function removeESP(player: Player)
	if state.espObjects[player] then
		state.espObjects[player]:Destroy()
		state.espObjects[player] = nil
	end
	if player.Character then
		local h = player.Character:FindFirstChild("ESP_Highlight")
		if h then h:Destroy() end
	end
end

local function getTargetParts(character: Model)
	local parts = {}
	for _, part in ipairs(character:GetDescendants()) do
		if part:IsA("BasePart") and (
			part.Name:match("Head") or
			part.Name:match("Torso") or
			part.Name:match("Chest") or
			part.Name:match("Upper") or
			part.Name:match("HumanoidRootPart")
		) then
			table.insert(parts, part)
		end
	end
	if #parts == 0 then
		local hrp = getCenterPart(character)
		if hrp then table.insert(parts, hrp) end
	end
	return parts
end

local function createHitbox(character: Model, player: Player)
	if not character or isSameTeam(LocalPlayer, player) then return end
	
	local targetParts = getTargetParts(character)
	if #targetParts == 0 then return end
	
	for _, originalPart in ipairs(targetParts) do
		if not originalPart:FindFirstChild("HitboxExtender") then
			local hitbox = Instance.new("Part")
			hitbox.Name = "HitboxExtender"
			hitbox.Size = Vector3.new(settings.hitboxSize, settings.hitboxSize, settings.hitboxSize)
			hitbox.Transparency = 1
			hitbox.CanCollide = false
			hitbox.Massless = true
			hitbox.CFrame = originalPart.CFrame
			hitbox.Anchored = false
			
			local weld = Instance.new("WeldConstraint")
			weld.Part0 = hitbox
			weld.Part1 = originalPart
			weld.Parent = hitbox
			
			for _, existing in ipairs(originalPart:GetChildren()) do
				if existing:IsA("BodyVelocity") or existing:IsA("BodyGyro") or existing:IsA("BodyPosition") then
					existing:Destroy()
				end
			end
			
			hitbox.Parent = character
			
			if not state.hitboxParts[player] then
				state.hitboxParts[player] = {}
			end
			table.insert(state.hitboxParts[player], hitbox)
		end
	end
end

local function removeHitbox(player: Player)
	if state.hitboxParts[player] then
		for _, hitbox in ipairs(state.hitboxParts[player]) do
			if hitbox and hitbox.Parent then
				hitbox:Destroy()
			end
		end
		state.hitboxParts[player] = nil
	end
	
	if player.Character then
		for _, part in ipairs(player.Character:GetDescendants()) do
			if part.Name == "HitboxExtender" then
				part:Destroy()
			end
		end
	end
end

local function hitboxLoop()
	if not settings.hitbox then return end
	
	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= LocalPlayer and player.Character then
			if not isSameTeam(LocalPlayer, player) then
				local char = player.Character
				local needsUpdate = false
				
				if not state.hitboxParts[player] or #state.hitboxParts[player] == 0 then
					needsUpdate = true
				else
					for _, hitbox in ipairs(state.hitboxParts[player]) do
						if not hitbox or not hitbox.Parent then
							needsUpdate = true
							break
						end
					end
				end
				
				if needsUpdate then
					removeHitbox(player)
					createHitbox(char, player)
				end
			else
				removeHitbox(player)
			end
		end
	end
end

local function noclipLoop()
	if not settings.noclip then return end
	
	local char = LocalPlayer.Character
	if not char then return end
	
	for _, part in ipairs(char:GetDescendants()) do
		if part:IsA("BasePart") then
			part.CanCollide = false
		end
	end
end

local function speedLoop()
	if not settings.speed then return end
	
	local char = LocalPlayer.Character
	if not char then return end
	
	local hrp = char:FindFirstChild("HumanoidRootPart")
	if not hrp then return end
	
	local moveDir = Vector3.zero
	
	if UserInputService:IsKeyDown(Enum.KeyCode.W) then
		moveDir += Camera.CFrame.LookVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.S) then
		moveDir -= Camera.CFrame.LookVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.A) then
		moveDir -= Camera.CFrame.RightVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.D) then
		moveDir += Camera.CFrame.RightVector
	end
	
	if moveDir.Magnitude > 0 then
		moveDir = Vector3.new(moveDir.X, 0, moveDir.Z).Unit
		local currentVel = hrp.AssemblyLinearVelocity
		hrp.AssemblyLinearVelocity = Vector3.new(
			moveDir.X * 16 * settings.speedMultiplier,
			currentVel.Y,
			moveDir.Z * 16 * settings.speedMultiplier
		)
	end
end

local function triggerbotLoop()
	if not settings.triggerbot then return end
	
	local now = tick()
	if now - state.lastShot < settings.triggerbotDelay then return end
	
	local mouse = LocalPlayer:GetMouse()
	local origin = Camera.CFrame.Position
	local direction = (mouse.Hit.Position - origin).Unit * settings.maxDistance
	
	local rayParams = RaycastParams.new()
	rayParams.FilterDescendantsInstances = {LocalPlayer.Character}
	rayParams.FilterType = Enum.RaycastFilterType.Exclude
	rayParams.IgnoreWater = true
	
	local result = Workspace:Raycast(origin, direction, rayParams)
	
	if result and result.Instance then
		local hitPart = result.Instance
		local hitChar = hitPart:FindFirstAncestorOfClass("Model")
		
		if hitChar and state.playerCharacters[hitChar] then
			local targetPlayer = state.playerCharacters[hitChar]
			
			if not isSameTeam(LocalPlayer, targetPlayer) then
				local hum = hitChar:FindFirstChild("Humanoid")
				if hum and hum.Health > 0 then
					local distance = (origin - result.Position).Magnitude
					
					if distance <= settings.maxDistance then
						mouse1click()
						state.lastShot = now
					end
				end
			end
		end
	end
end

local function aimbotLoop()
	if not settings.aimbot then 
		if state.isHoldingClick then
			mouse1release()
			state.isHoldingClick = false
		end
		if state.fovCircle then
			state.fovCircle.Visible = false
		end
		return 
	end
	
	if state.fovCircle then
		state.fovCircle.Radius = settings.aimbotFOV
		state.fovCircle.Position = Vector2.new(Camera.ViewportSize.X/2, Camera.ViewportSize.Y/2)
		state.fovCircle.Visible = settings.aimbot
	end
	
	local candidates = {}
	local mousePos = Vector2.new(Camera.ViewportSize.X/2, Camera.ViewportSize.Y/2)
	
	for player, parts in pairs(state.cachedParts) do
		if player.Character and not isSameTeam(LocalPlayer, player) then
			-- Check custom health system (workspace.Game.Players.[team].[player].Health.Value)
			local isAlive = false
			local gameFolder = Workspace:FindFirstChild("Game")
			if gameFolder then
				local playersFolder = gameFolder:FindFirstChild("Players")
				if playersFolder then
					-- Check both teams
					for _, teamName in ipairs({"Blue", "Green"}) do
						local teamFolder = playersFolder:FindFirstChild(teamName)
						if teamFolder then
							local playerFolder = teamFolder:FindFirstChild(player.Name)
							if playerFolder then
								local healthValue = playerFolder:FindFirstChild("Health")
								if healthValue and healthValue:IsA("NumberValue") or healthValue:IsA("IntValue") then
									if healthValue.Value > 0 then
										isAlive = true
									end
								end
								break
							end
						end
					end
				end
			end
			
			if isAlive then
			-- check head
			if parts.Head then
				local screenPos, onScreen = Camera:WorldToViewportPoint(parts.Head.Position)
				if onScreen then
					local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude
					if dist <= settings.aimbotFOV then
						table.insert(candidates, {part = parts.Head, player = player, dist = dist, priority = 2})
					end
				end
			end
			-- check body parts
			for _, part in ipairs(parts.Body) do
				local screenPos, onScreen = Camera:WorldToViewportPoint(part.Position)
				if onScreen then
					local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude
					if dist <= settings.aimbotFOV then
						table.insert(candidates, {part = part, player = player, dist = dist, priority = 1})
					end
				end
			end
			end
		end
	end
	
	local nearestPlayer = nil
	local nearestPart = nil
	
	if #candidates > 0 then
		-- Sort: Priority (Head > Body) then Distance
		table.sort(candidates, function(a, b)
			if a.priority ~= b.priority then
				return a.priority > b.priority
			end
			return a.dist < b.dist
		end)
		
		-- Only raycast for the best candidates (limit to top 3 to prevent lag)
		local raycastLimit = 3
		local raycastCount = 0
		
		for _, cand in ipairs(candidates) do
			if raycastCount >= raycastLimit then break end
			raycastCount += 1
			
			local rayParams = RaycastParams.new()
			rayParams.FilterDescendantsInstances = {LocalPlayer.Character, cand.player.Character}
			rayParams.FilterType = Enum.RaycastFilterType.Exclude
			rayParams.IgnoreWater = true
			
			local origin = Camera.CFrame.Position
			local direction = (cand.part.Position - origin)
			local result = Workspace:Raycast(origin, direction, rayParams)
			
			if not result then
				nearestPlayer = cand.player
				nearestPart = cand.part
				break
			end
		end
	end
	
	if nearestPlayer and nearestPart and settings.aimbot then
		print("Target detected: " .. nearestPlayer.Name)
		Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, nearestPart.Position)
		
		local now = tick()
		if settings.aimbotHoldClick then
			if not state.isHoldingClick then
				mouse1press()
				state.isHoldingClick = true
			end
		elseif settings.aimbotSpam or (now - state.lastShot >= settings.triggerbotDelay) then
			mouse1click()
			state.lastShot = now
		end
	end

	if (not nearestPlayer or not nearestPart) and state.isHoldingClick then
		mouse1release()
		state.isHoldingClick = false
	end
end

local function infJumpLoop()
	if not settings.infjump then return end
	if not state.canJump then return end
	
	local char = LocalPlayer.Character
	if not char then return end
	
	local hrp = char:FindFirstChild("HumanoidRootPart")
	if not hrp then return end
	
	local vel = Instance.new("BodyVelocity")
	vel.Velocity = Vector3.new(hrp.AssemblyLinearVelocity.X, settings.jumpPower, hrp.AssemblyLinearVelocity.Z)
	vel.MaxForce = Vector3.new(0, math.huge, 0)
	vel.Parent = hrp
	
	state.canJump = false
	task.wait(0.1)
	vel:Destroy()
	task.wait(0.15)
	state.canJump = true
end

-- Toggle Functions
function toggleESP()
	settings.esp = not settings.esp
	
	if settings.esp then
		for _, p in ipairs(Players:GetPlayers()) do
			if p ~= LocalPlayer then
				applyESP(p)
			end
		end
	else
		for _, p in ipairs(Players:GetPlayers()) do
			removeESP(p)
		end
		state.espObjects = {}
	end
end

function toggleNoclip()
	settings.noclip = not settings.noclip
	
	if settings.noclip then
		if not state.noclipConnection then
			state.noclipConnection = RunService.Stepped:Connect(noclipLoop)
		end
	else
		if state.noclipConnection then
			state.noclipConnection:Disconnect()
			state.noclipConnection = nil
		end
		local char = LocalPlayer.Character
		if char then
			for _, part in ipairs(char:GetDescendants()) do
				if part:IsA("BasePart") then
					part.CanCollide = true
				end
			end
		end
	end
end

function toggleTeamCheck()
	settings.teamCheck = not settings.teamCheck
	
	if settings.esp then
		for _, p in ipairs(Players:GetPlayers()) do
			if p ~= LocalPlayer and p.Character then
				local h = p.Character:FindFirstChild("ESP_Highlight")
				if h then
					h.FillColor = isSameTeam(LocalPlayer, p)
						and Color3.fromRGB(255, 255, 255)
						or Color3.fromRGB(255, 0, 0)
				end
			end
		end
	end
end

function toggleFogRemover()
	settings.fogRemover = not settings.fogRemover
	
	if settings.fogRemover then
		disableFog()
	else
		enableFog()
	end
end

function toggleHitbox()
	settings.hitbox = not settings.hitbox
	
	if settings.hitbox then
		if not state.hitboxConnection then
			state.hitboxConnection = RunService.Heartbeat:Connect(hitboxLoop)
		end
		for _, p in ipairs(Players:GetPlayers()) do
			if p ~= LocalPlayer and p.Character then
				createHitbox(p.Character, p)
			end
		end
	else
		if state.hitboxConnection then
			state.hitboxConnection:Disconnect()
			state.hitboxConnection = nil
		end
		for _, p in ipairs(Players:GetPlayers()) do
			removeHitbox(p)
		end
		state.hitboxParts = {}
	end
end

function toggleInfJump()
	settings.infjump = not settings.infjump
	state.canJump = true
end

function toggleSpeed()
	settings.speed = not settings.speed
	
	if settings.speed then
		if not state.speedConnection then
			state.speedConnection = RunService.Heartbeat:Connect(speedLoop)
		end
	else
		if state.speedConnection then
			state.speedConnection:Disconnect()
			state.speedConnection = nil
		end
	end
end

function toggleTriggerbot()
	settings.triggerbot = not settings.triggerbot
	
	if settings.triggerbot then
		updatePlayerCache()
		if not state.triggerbotConnection then
			state.triggerbotConnection = RunService.RenderStepped:Connect(triggerbotLoop)
		end
	else
		if state.triggerbotConnection then
			state.triggerbotConnection:Disconnect()
			state.triggerbotConnection = nil
		end
	end
end

function toggleAimbot()
	settings.aimbot = not settings.aimbot
	
	if state.fovCircle then
		state.fovCircle.Visible = settings.aimbot
	end
	
	if settings.aimbot then
		updatePlayerCache()
		if not state.aimbotConnection then
			state.aimbotConnection = RunService.RenderStepped:Connect(aimbotLoop)
		end
	else
		if state.aimbotConnection then
			state.aimbotConnection:Disconnect()
			state.aimbotConnection = nil
		end
	end
end

function toggleGrenadeHitbox()
	settings.grenadeHitbox = not settings.grenadeHitbox
	
	if settings.grenadeHitbox then
		if not state.grenadeHitboxConnection then
			local gameFolder = Workspace:FindFirstChild("Game")
			if gameFolder then
				local projectilesFolder = gameFolder:FindFirstChild("Projectiles")
				if projectilesFolder then
					state.grenadeHitboxConnection = projectilesFolder.ChildAdded:Connect(function(grenade)
						-- Check if grenade is named after LocalPlayer
						if grenade.Name == LocalPlayer.Name then
							task.wait(0.1) -- Wait for hitbox to be created
							local hitbox = grenade:FindFirstChild("Hitbox")
							if hitbox and hitbox:IsA("BasePart") then
								hitbox.Size = Vector3.new(settings.grenadeHitboxSize, settings.grenadeHitboxSize, settings.grenadeHitboxSize)
							end
						end
					end)
				end
			end
		end
	else
		if state.grenadeHitboxConnection then
			state.grenadeHitboxConnection:Disconnect()
			state.grenadeHitboxConnection = nil
		end
	end
end

function toggleAutoFollow()
	settings.autoFollowEnemy = not settings.autoFollowEnemy
	if settings.autoFollowEnemy then
		if not state.autoFollowConnection then
			state.autoFollowConnection = RunService.Heartbeat:Connect(autoFollowLoop)
		end
	else
		if state.autoFollowConnection then
			state.autoFollowConnection:Disconnect()
			state.autoFollowConnection = nil
		end
		state.currentFollowTarget = nil
	end
end

local function freeCamLoop()
	if not settings.freeCam then return end
	
	local speed = 1
	if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then
		speed = 2
	end
	
	local moveDir = Vector3.zero
	if UserInputService:IsKeyDown(Enum.KeyCode.W) then
		moveDir += Camera.CFrame.LookVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.S) then
		moveDir -= Camera.CFrame.LookVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.A) then
		moveDir -= Camera.CFrame.RightVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.D) then
		moveDir += Camera.CFrame.RightVector
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.E) or UserInputService:IsKeyDown(Enum.KeyCode.Space) then
		moveDir += Vector3.new(0, 1, 0)
	end
	if UserInputService:IsKeyDown(Enum.KeyCode.Q) or UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
		moveDir -= Vector3.new(0, 1, 0)
	end
	
	if moveDir.Magnitude > 0 then
		moveDir = moveDir.Unit * speed
		Camera.CFrame = Camera.CFrame + moveDir
	end
end

function toggleFreeCam()
	settings.freeCam = not settings.freeCam
	
	if settings.freeCam then
		state.originalCamSubject = Camera.CameraSubject
		Camera.CameraType = Enum.CameraType.Custom
		Camera.CameraSubject = nil
		if not state.freeCamConnection then
			state.freeCamConnection = RunService.RenderStepped:Connect(freeCamLoop)
		end
	else
		if state.freeCamConnection then
			state.freeCamConnection:Disconnect()
			state.freeCamConnection = nil
		end
		Camera.CameraType = Enum.CameraType.Custom
		if state.originalCamSubject then
			Camera.CameraSubject = state.originalCamSubject
		else
			local char = LocalPlayer.Character
			if char then
				local hum = char:FindFirstChild("Humanoid")
				if hum then
					Camera.CameraSubject = hum
				end
			end
		end
	end
end

function toggleInvisibility()
	settings.invisibility = not settings.invisibility
	local char = LocalPlayer.Character
	if not char then return end
	for _, part in ipairs(char:GetDescendants()) do
		if part:IsA("BasePart") or part:IsA("MeshPart") or part:IsA("Part") then
			if settings.invisibility then
				part.Transparency = 1
			else
				if part.Name == "Head" then
					part.Transparency = 0
				else
					part.Transparency = 0
				end
			end
		end
		if part:IsA("Decal") or part:IsA("Texture") then
			part.Transparency = settings.invisibility and 1 or 0
		end
	end
end

local function tpEnemiesInFrontLoop()
	if not settings.tpEnemiesInFront then return end
	
	local myChar = LocalPlayer.Character
	if not myChar then return end
	
	local myHRP = myChar:FindFirstChild("HumanoidRootPart")
	if not myHRP then return end
	
	-- Get camera position and look direction
	local camCFrame = Camera.CFrame
	local camPos = camCFrame.Position
	local camLook = camCFrame.LookVector
	
	-- Position enemies in front of camera (5 studs away)
	local targetPosition = camPos + (camLook * 5)
	
	-- Find all enemies and teleport them
	local gameFolder = Workspace:FindFirstChild("Game")
	if gameFolder then
		local playersFolder = gameFolder:FindFirstChild("Players")
		if playersFolder then
			for _, p in ipairs(Players:GetPlayers()) do
				if p ~= LocalPlayer and p.Character and not isSameTeam(LocalPlayer, p) then
					-- Check if player is alive
					local isAlive = false
					for _, teamName in ipairs({"Blue", "Green"}) do
						local teamFolder = playersFolder:FindFirstChild(teamName)
						if teamFolder then
							local playerFolder = teamFolder:FindFirstChild(p.Name)
							if playerFolder then
								local healthValue = playerFolder:FindFirstChild("Health")
								if healthValue and (healthValue:IsA("NumberValue") or healthValue:IsA("IntValue")) then
									if healthValue.Value > 0 then
										isAlive = true
									end
								end
								break
							end
						end
					end
					
					-- Teleport if alive
					if isAlive then
						local enemyHRP = p.Character:FindFirstChild("HumanoidRootPart")
						if enemyHRP then
							enemyHRP.CFrame = CFrame.new(targetPosition)
						end
					end
				end
			end
		end
	end
end

-- Tracers Logic
local function updateTracers()
	if not settings.tracers then return end
	
	for _, p in ipairs(Players:GetPlayers()) do
		if p ~= LocalPlayer and p.Character then
			-- Ensure drawing object exists
			if not state.tracerDrawings[p] then
				if Drawing then
					local line = Drawing.new("Line")
					line.Visible = false
					line.Thickness = 1.5
					line.Color = Color3.fromRGB(255, 255, 255)
					state.tracerDrawings[p] = line
				end
			end
			
			local line = state.tracerDrawings[p]
			if line then
				local char = p.Character
				local hrp = char:FindFirstChild("HumanoidRootPart")
				
				local showing = false
				
				if hrp and (not settings.teamCheck or not isSameTeam(LocalPlayer, p)) then
					-- Check alive
					local isAlive = true -- Basic check, can be improved with Health value check like others
					local hum = char:FindFirstChild("Humanoid")
					if hum and hum.Health <= 0 then isAlive = false end
					
					if isAlive then
						local screenPos, onScreen = Camera:WorldToViewportPoint(hrp.Position)
						if onScreen then
							line.From = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y) -- Bottom middle
							line.To = Vector2.new(screenPos.X, screenPos.Y)
							
							if settings.teamCheck then
								line.Color = isSameTeam(LocalPlayer, p) and Color3.new(0, 1, 0) or Color3.new(1, 0, 0)
							else
								line.Color = Color3.new(1, 1, 1)
							end
							
							line.Visible = true
							showing = true
						end
					end
				end
				
				if not showing then
					line.Visible = false
				end
			end
		end
	end
	
	-- Cleanup invalid players
	for p, line in pairs(state.tracerDrawings) do
		if not p.Parent then
			line.Visible = false
			line:Remove()
			state.tracerDrawings[p] = nil
		end
	end
end

local function removeTracers()
	for _, line in pairs(state.tracerDrawings) do
		line.Visible = false
		line:Remove()
	end
	state.tracerDrawings = {}
end

-- Auto TP Kill Logic
local function autoTPKillLoop()
	if not settings.autoTPKill then return end
	
	local now = tick()
	if now - state.lastAutoTP < settings.autoTPDelay then return end
	
	local target = getRandomEnemy()
	if target and target.Character then
		local targetHRP = target.Character:FindFirstChild("HumanoidRootPart")
		local myChar = LocalPlayer.Character
		if targetHRP and myChar then
			local myHRP = myChar:FindFirstChild("HumanoidRootPart")
			if myHRP then
				-- TP Behind and Look at Target
				local behindPos = targetHRP.CFrame * CFrame.new(0, 0, 3)
				myHRP.CFrame = CFrame.lookAt(behindPos.Position, targetHRP.Position) 
				-- Look at target
				Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, targetHRP.Position)
				
				-- Shoot
				mouse1click()
				
				state.lastAutoTP = now
			end
		end
	end
end

-- Anticheat Bypass Logic (Speed Bypass)
local function enableAnticheatBypass()
    -- Logic extracted from anticheatbypass file
    -- This attempts to mimic the AC handshake or disable the kick
    if settings.anticheatBypass then
        local v3 = game:GetService("ReplicatedStorage")
        local v_u_6 = v3:WaitForChild("TemperatureCheck", 5)
        local v_u_7 = v3:WaitForChild("TemperatureConfirm", 5)

        if not v_u_6 or not v_u_7 then 
             -- notification "AC Bypass Failed: Remotes not found"
             return 
        end
        
        -- The complex math function from the source file
        local function v_u_43(p_u_10, p_u_11, p_u_12, p13)
            local v_u_14
            if typeof(p_u_10) == "number" then
                local v15 = p_u_10 % 2147483648
                v_u_14 = math.floor(v15)
            else
                v_u_14 = tonumber(p_u_10) or 0
            end
            for _, v16 in ipairs(p13) do
                local function v27(p17)
                    if p17 == "challenge" then
                        local v18 = p_u_10
                        if typeof(v18) ~= "number" then
                            return tonumber(v18) or 0
                        end
                        local v19 = v18 % 2147483648
                        return math.floor(v19)
                    end
                    if p17 == "secret" then
                        local v20 = p_u_11
                        if typeof(v20) ~= "number" then
                            return tonumber(v20) or 0
                        end
                        local v21 = v20 % 2147483648
                        return math.floor(v21)
                    end
                    if p17 == "userId" then
                        local v22 = p_u_12
                        if typeof(v22) ~= "number" then
                            return tonumber(v22) or 0
                        end
                        local v23 = v22 % 2147483648
                        return math.floor(v23)
                    end
                    if p17 ~= "prev" then
                        if typeof(p17) ~= "number" then
                            return tonumber(p17) or 0
                        end
                        local v24 = p17 % 2147483648
                        return math.floor(v24)
                    end
                    local v25 = v_u_14
                    if typeof(v25) ~= "number" then
                        return tonumber(v25) or 0
                    end
                    local v26 = v25 % 2147483648
                    return math.floor(v26)
                end
                local v28 = v27(v16.a)
                local v29 = v27(v16.b)
                local v30
                if v16.op == "add" then
                    local v31 = v28 + v29
                    if typeof(v31) == "number" then
                        local v32 = v31 % 2147483648
                        v30 = math.floor(v32)
                        v_u_14 = v30
                    else
                        v30 = tonumber(v31) or 0
                        v_u_14 = v30
                    end
                elseif v16.op == "sub" then
                    local v33 = v28 - v29
                    if typeof(v33) == "number" then
                        local v34 = v33 % 2147483648
                        v30 = math.floor(v34)
                        v_u_14 = v30
                    else
                        v30 = tonumber(v33) or 0
                        v_u_14 = v30
                    end
                elseif v16.op == "mul" then
                    local v35 = v28 * v29
                    if typeof(v35) == "number" then
                        local v36 = v35 % 2147483648
                        v30 = math.floor(v36)
                        v_u_14 = v30
                    else
                        v30 = tonumber(v35) or 0
                        v_u_14 = v30
                    end
                elseif v16.op == "mod" then
                    local v37
                    if v29 == 0 then
                        v37 = 0
                    else
                        local v38 = v28 % v29
                        local v39
                        if typeof(v38) == "number" then
                            local v40 = v38 % 2147483648
                            v39 = math.floor(v40)
                        else
                            v39 = tonumber(v38) or 0
                        end
                        v37 = v39 or 0
                    end
                    v30 = v37
                    v_u_14 = v30
                elseif v16.op == "bxor" then
                    v30 = bit32.bxor(v28, v29)
                    v_u_14 = v30
                end
            end
            local v41
            if typeof(v_u_14) == "number" then
                local v42 = v_u_14 % 2147483648
                v41 = math.floor(v42)
            else
                v41 = tonumber(v_u_14) or 0
            end
            return v41
        end

        -- Start the validation loop
        task.spawn(function()
            while settings.anticheatBypass do
                local success, result = pcall(function()
                    return v_u_6:InvokeServer()
                end)
                if success and typeof(result) == "table" and result.challenge and result.secret and result.userId and result.ops then
                     v_u_7:FireServer((v_u_43(result.challenge, result.secret, result.userId, result.ops)))
                end
                task.wait(5)
            end
        end)
    end
end


function toggleTpEnemiesInFront()
	settings.tpEnemiesInFront = not settings.tpEnemiesInFront
	
	if settings.tpEnemiesInFront then
		if not state.tpEnemiesConnection then
			state.tpEnemiesConnection = RunService.Heartbeat:Connect(tpEnemiesInFrontLoop)
		end
	else
		if state.tpEnemiesConnection then
			state.tpEnemiesConnection:Disconnect()
			state.tpEnemiesConnection = nil
		end
	end
end

function toggleTracers()
	settings.tracers = not settings.tracers
	
	if settings.tracers then
		if not state.tracersConnection then
			state.tracersConnection = RunService.RenderStepped:Connect(updateTracers)
		end
	else
		if state.tracersConnection then
			state.tracersConnection:Disconnect()
			state.tracersConnection = nil
		end
		removeTracers()
	end
end

function toggleAutoTPKill()
	settings.autoTPKill = not settings.autoTPKill
	
	if settings.autoTPKill then
		if not state.autoTPKillConnection then
			state.autoTPKillConnection = RunService.Heartbeat:Connect(autoTPKillLoop)
		end
	else
		if state.autoTPKillConnection then
			state.autoTPKillConnection:Disconnect()
			state.autoTPKillConnection = nil
		end
	end
end

local function hitboxScaleLoop()
	if not settings.hitboxScale then return end
	
	local gameFolder = Workspace:FindFirstChild("Game")
	if not gameFolder then return end
	
	local playersFolder = gameFolder:FindFirstChild("Players")
	if not playersFolder then return end
	
	for _, p in ipairs(Players:GetPlayers()) do
		if p ~= LocalPlayer and not isSameTeam(LocalPlayer, p) then
			-- Find the "Hitbox" part in the player's team folder
			for _, teamName in ipairs({"Blue", "Green"}) do
				local teamFolder = playersFolder:FindFirstChild(teamName)
				if teamFolder then
					local playerFolder = teamFolder:FindFirstChild(p.Name)
					if playerFolder then
						local hitboxPart = playerFolder:FindFirstChild("Hitbox")
						if hitboxPart and hitboxPart:IsA("BasePart") then
							-- Store original size if not already saved
							if not state.originalHitboxSizes[hitboxPart] then
								state.originalHitboxSizes[hitboxPart] = hitboxPart.Size
							end
							
							-- Scale up
							local targetSize = Vector3.new(settings.hitboxScaleSize, settings.hitboxScaleSize, settings.hitboxScaleSize)
							if hitboxPart.Size ~= targetSize then
								hitboxPart.Size = targetSize
								hitboxPart.CanCollide = false -- Prevent physics collision issues
							end
						end
						break
					end
				end
			end
		end
	end
end

function toggleHitboxScale()
	settings.hitboxScale = not settings.hitboxScale
	
	if settings.hitboxScale then
		if not state.hitboxScaleConnection then
			state.hitboxScaleConnection = RunService.Heartbeat:Connect(hitboxScaleLoop)
		end
	else
		if state.hitboxScaleConnection then
			state.hitboxScaleConnection:Disconnect()
			state.hitboxScaleConnection = nil
		end
		
		-- Restore original sizes
		for part, size in pairs(state.originalHitboxSizes) do
			if part and part.Parent then
				part.Size = size
			end
		end
		state.originalHitboxSizes = {}
	end
end

local function fullBrightLoop()
	if not settings.fullBright then return end
	enableFullBright()
end

function toggleFullBright()
	settings.fullBright = not settings.fullBright
	
	if settings.fullBright then
		enableFullBright()
		if not state.fullBrightConnection then
			state.fullBrightConnection = RunService.RenderStepped:Connect(fullBrightLoop)
		end
	else
		if state.fullBrightConnection then
			state.fullBrightConnection:Disconnect()
			state.fullBrightConnection = nil
		end
		disableFullBright()
	end
end


function toggleStatsHUD()
	settings.statsHUD = not settings.statsHUD
	
	if settings.statsHUD then
		createStatsHUD()
		if not state.statsHUDConnection then
			state.statsHUDConnection = RunService.RenderStepped:Connect(updateStatsHUD)
		end
	else
		if state.statsHUDConnection then
			state.statsHUDConnection:Disconnect()
			state.statsHUDConnection = nil
		end
		removeStatsHUD()
	end
end


local function safeWalkLoop()
	if not settings.safeWalk then return end
	
	local char = LocalPlayer.Character
	if not char then return end
	
	local hrp = char:FindFirstChild("HumanoidRootPart")
	if not hrp then return end
	
	-- Only place blocks if moving or falling
	if hrp.AssemblyLinearVelocity.Magnitude > 0.1 then
		local pos = hrp.Position
		local blockPos = Vector3.new(pos.X, pos.Y - 3.5, pos.Z)
		
		-- Check if there's already a safe block nearby
		local tooClose = false
		for _, block in ipairs(state.safeWalkBlocks) do
			if block and block.Parent and (block.Position - blockPos).Magnitude < 2 then
				tooClose = true
				break
			end
		end
		
		if not tooClose then
			local block = Instance.new("Part")
			block.Name = "SafeWalkBlock"
			block.Size = Vector3.new(4, 1, 4)
			block.Position = blockPos
			block.Anchored = true
			block.Transparency = 1
			block.CanCollide = true
			block.Parent = Workspace
			table.insert(state.safeWalkBlocks, block)
		end
	end
end

function toggleSafeWalk()
	settings.safeWalk = not settings.safeWalk
	
	if settings.safeWalk then
		if not state.safeWalkConnection then
			state.safeWalkConnection = RunService.Heartbeat:Connect(safeWalkLoop)
		end
	else
		if state.safeWalkConnection then
			state.safeWalkConnection:Disconnect()
			state.safeWalkConnection = nil
		end
		-- Cleanup blocks
		for _, block in ipairs(state.safeWalkBlocks) do
			if block and block.Parent then
				block:Destroy()
			end
		end
		state.safeWalkBlocks = {}
	end
end

local function healthLockLoop()
	if not settings.healthLock then return end
	
	local gameFolder = Workspace:FindFirstChild("Game")
	if not gameFolder then return end
	
	local playersFolder = gameFolder:FindFirstChild("Players")
	if not playersFolder then return end
	
	-- Check both Blue and Green team folders for the local player
	for _, teamName in ipairs({"Blue", "Green"}) do
		local teamFolder = playersFolder:FindFirstChild(teamName)
		if teamFolder then
			local playerFolder = teamFolder:FindFirstChild(LocalPlayer.Name)
			if playerFolder then
				local healthValue = playerFolder:FindFirstChild("Health")
				if healthValue and (healthValue:IsA("NumberValue") or healthValue:IsA("IntValue")) then
					if healthValue.Value ~= 300 then
					wait(1)
						healthValue.Value = 300
					end
					break
				end
			end
		end
	end
end

function toggleHealthLock()
	settings.healthLock = not settings.healthLock
	
	if settings.healthLock then
		if not state.healthLockConnection then
			state.healthLockConnection = RunService.Heartbeat:Connect(healthLockLoop)
		end
	else
		if state.healthLockConnection then
			state.healthLockConnection:Disconnect()
			state.healthLockConnection = nil
		end
	end
end




-- Populate UI
-- Visuals
createToggleUI(visualsPage, "ESP", "esp", toggleESP, settings.keybinds.esp)
createToggleUI(visualsPage, "Team Check", "teamCheck", toggleTeamCheck, settings.keybinds.teamCheck)
createToggleUI(visualsPage, "Fog Remover", "fogRemover", toggleFogRemover, settings.keybinds.fogRemover)
createToggleUI(visualsPage, "Tracers", "tracers", toggleTracers, settings.keybinds.tracers)

-- Combat
createToggleUI(combatPage, "Aimbot", "aimbot", toggleAimbot, settings.keybinds.aimbot)
createSliderUI(combatPage, "Aimbot FOV", 20, 600, "aimbotFOV")
createToggleUI(combatPage, "Triggerbot", "triggerbot", toggleTriggerbot, settings.keybinds.triggerbot)
createSliderUI(combatPage, "Trigger Distance", 50, 1000, "maxDistance")
createSliderUI(combatPage, "Trigger Delay", 0.05, 1, "triggerbotDelay")
createToggleUI(combatPage, "Hitbox Expand", "hitbox", toggleHitbox, settings.keybinds.hitbox)
createSliderUI(combatPage, "Hitbox Size", 1, 30, "hitboxSize")

-- Movement
createToggleUI(movementPage, "Noclip", "noclip", toggleNoclip, settings.keybinds.noclip)
createToggleUI(movementPage, "Infinite Jump", "infjump", toggleInfJump, settings.keybinds.infjump)
createToggleUI(movementPage, "Speed Hack", "speed", toggleSpeed, settings.keybinds.speed)
createSliderUI(movementPage, "Speed Multiplier", 1, 10, "speedMultiplier")
createSliderUI(movementPage, "Jump Power", 50, 200, "jumpPower")

-- Experimental
createWarningUI(experimentalPage, "EXPERIMENTAL FEATURES MAY BE UNSTABLE")
createToggleUI(experimentalPage, "Grenade Hitbox", "grenadeHitbox", toggleGrenadeHitbox, Enum.KeyCode.Unknown)
createSliderUI(experimentalPage, "Grenade Size", 1, 100, "grenadeHitboxSize")
createToggleUI(experimentalPage, "Auto-Follow Enemy", "autoFollowEnemy", toggleAutoFollow, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Invisibility", "invisibility", toggleInvisibility, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Free Cam", "freeCam", toggleFreeCam, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "TP Enemies to Camera", "tpEnemiesInFront", toggleTpEnemiesInFront, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Hitbox Scale (Team)", "hitboxScale", toggleHitboxScale, Enum.KeyCode.Unknown)
createSliderUI(experimentalPage, "Hitbox Scale Size", 10, 500, "hitboxScaleSize")
createButtonUI(experimentalPage, "Anticheat Bypass", function()
    settings.anticheatBypass = not settings.anticheatBypass
    if settings.anticheatBypass then
        enableAnticheatBypass()
    end
end)
createToggleUI(experimentalPage, "Auto TP & Kill", "autoTPKill", toggleAutoTPKill, settings.keybinds.autoTPKill)
createSliderUI(experimentalPage, "Auto TP Delay", 0.1, 2, "autoTPDelay")
createToggleUI(experimentalPage, "Full Bright", "fullBright", toggleFullBright, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Safe Walk", "safeWalk", toggleSafeWalk, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Aimbot SMG Spam", "aimbotSpam", function() settings.aimbotSpam = not settings.aimbotSpam end, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Aimbot Hold Click", "aimbotHoldClick", function() settings.aimbotHoldClick = not settings.aimbotHoldClick; if not settings.aimbotHoldClick and state.isHoldingClick then mouse1release(); state.isHoldingClick = false end end, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Stats HUD", "statsHUD", toggleStatsHUD, Enum.KeyCode.Unknown)
createToggleUI(experimentalPage, "Health Lock (100)", "healthLock", toggleHealthLock, Enum.KeyCode.Unknown)


-- Finalize
if Drawing then
	state.fovCircle = Drawing.new("Circle")
	state.fovCircle.Visible = false
	state.fovCircle.Thickness = 1
	state.fovCircle.Color = Color3.fromRGB(255, 255, 255)
	state.fovCircle.Transparency = 1
	state.fovCircle.Filled = false
	state.fovCircle.Radius = settings.aimbotFOV
	state.fovCircle.Position = Vector2.new(Camera.ViewportSize.X/2, Camera.ViewportSize.Y/2)
end

-- Input Handling for Keybinds
UserInputService.InputBegan:Connect(function(input, gp)
	if gp then return end
	
	if state.changingKeybind then
		if input.KeyCode ~= Enum.KeyCode.Unknown and input.KeyCode ~= Enum.KeyCode.Escape then
			settings.keybinds[state.changingKeybind.setting] = input.KeyCode
			state.changingKeybind.updateUI(input.KeyCode)
		end
		state.changingKeybind = nil
		return
	end
	
	for setting, keycode in pairs(settings.keybinds) do
		if input.KeyCode == keycode then
			if setting == "esp" then toggleESP()
			elseif setting == "noclip" then toggleNoclip()
			elseif setting == "teamCheck" then toggleTeamCheck()
			elseif setting == "fogRemover" then toggleFogRemover()
			elseif setting == "hitbox" then toggleHitbox()
			elseif setting == "infjump" then toggleInfJump()
			elseif setting == "speed" then toggleSpeed()
			elseif setting == "triggerbot" then toggleTriggerbot()
			elseif setting == "aimbot" then toggleAimbot()
			elseif setting == "tracers" then toggleTracers()
			elseif setting == "autoTPKill" then toggleAutoTPKill()
			end
			-- Update UI toggle to match state
			if state.toggleUpdaters[setting] then
				state.toggleUpdaters[setting](settings[setting])
			end
		end
	end
	
	if input.KeyCode == Enum.KeyCode.Space and settings.infjump then
		infJumpLoop()
	end
end)

-- Main setup
gui.Parent = game:GetService("CoreGui")
-- Show first tab by default
visualsPage.Visible = true
TweenService:Create(visualsBtn, TweenInfo.new(0.2), {TextColor3 = colors.text, BackgroundColor3 = colors.accent}):Play()

-- Initial Connections
Players.PlayerAdded:Connect(function(p)
	if p ~= LocalPlayer then
		if settings.esp then
			applyESP(p)
		end
		p.CharacterAdded:Connect(function(char)
			task.wait(0.5)
			updatePlayerCache()
			if settings.hitbox then
				createHitbox(char, p)
			end
		end)
		if p.Character then
			updatePlayerCache()
			if settings.hitbox then
				createHitbox(p.Character, p)
			end
		end
	end
end)

Players.PlayerRemoving:Connect(function(p)
	state.espObjects[p] = nil
	removeHitbox(p)
	updatePlayerCache()
end)

LocalPlayer.CharacterAdded:Connect(function()
	task.wait(0.5)
	state.canJump = true
	updatePlayerCache()
	
	if settings.noclip and not state.noclipConnection then
		state.noclipConnection = RunService.Stepped:Connect(noclipLoop)
	end
	if settings.speed and not state.speedConnection then
		state.speedConnection = RunService.Heartbeat:Connect(speedLoop)
	end
	if settings.triggerbot and not state.triggerbotConnection then
		state.triggerbotConnection = RunService.RenderStepped:Connect(triggerbotLoop)
	end
	if settings.aimbot and not state.aimbotConnection then
		state.aimbotConnection = RunService.RenderStepped:Connect(aimbotLoop)
	end
	if settings.tracers and not state.tracersConnection then
		state.tracersConnection = RunService.RenderStepped:Connect(updateTracers)
	end
	if settings.autoTPKill and not state.autoTPKillConnection then
		state.autoTPKillConnection = RunService.Heartbeat:Connect(autoTPKillLoop)
	end
end)

if settings.fogRemover then
	disableFog()
	RunService.RenderStepped:Connect(function()
		if settings.fogRemover then
			disableFog()
		end
	end)
end

RunService.Heartbeat:Connect(function()
	if settings.triggerbot or settings.aimbot then
		updatePlayerCache()
	end
end)

updatePlayerCache()

Features & Information

Aimbot full bright experimental features might not work (last time i played everything worked) also when using aimbot and want to use a smg or something like that enable its setting in experimental future tab (will optimize the whole thing soon for worse pc) made by claude credits to this script i use some stuff from it https://scriptblox.com/script/ArmsOfSolitaire-BETA-basic-menu-gui-57960
#ArmsOfSolitaire BETA#open source

Community Comments (6)

FreeHorizionFreeHorizionJan 14, 2026

hey whats ur disc?

Replying to @FreeHorizion
TEAM_TRXTEAM_TRXJan 14, 2026

@FreeHorizion aaltaccount0891

Replying to @TEAM_TRX
FreeHorizionFreeHorizionJan 14, 2026

@TEAM_TRX and also the script is good

Replying to @FreeHorizion
TEAM_TRXTEAM_TRXJan 14, 2026

@FreeHorizion tysm what game next (v2 of this script will be much more powerfull)

FreeHorizionFreeHorizionJan 14, 2026

says its not an account

Replying to @FreeHorizion
TEAM_TRXTEAM_TRXJan 14, 2026

@FreeHorizion aaltaccount0791

More Scripts for ArmsOfSolitaire BETA