Home All Scripts Trending Forum Upload Script Login with Google
Elemental Magic Showdown Script Keyless Auto Farm Levels 🔓 Keyless

Elemental Magic Showdown Script Keyless Auto Farm Levels

32 views  •  2 weeks ago
E
Elemental Magic Showdown
32 views 2 weeks ago #ElementalMagicShowdown

Farming in Elemental Magic Showdown is fun until you realize how long it actually takes to progress manually. This script handles the heavy lifting with features like Kill Aura and AutoFarm, letting you focus on the parts of the game you actually enjoy. It runs smoothly with no key needed required.

What This Script Can Do

  • Kill Aura: Automatically deals damage to nearby players within a set range, helping you secure kills in Elemental Magic Showdown combat situations.
  • AutoFarm: Automatically collects resources and repeats farming actions in Elemental Magic Showdown without any manual input from you.
  • Speed Hack: Boosts your character’s movement speed so you can get around Elemental Magic Showdown’s map much faster than normal.
  • Infinite jump: Lets you jump multiple times in the air, which is especially helpful for reaching high platforms or skipping obby sections.
  • Access: No key system or Linkvertise redirect needed — just paste and run.
  • Executor Compatibility: Works great on Delta, Codex, Hydrogen, Wave, and most mobile and PC executors.

How to Use This Script

  1. Start Roblox and join a Elemental Magic Showdown server — any public server works fine.
  2. Wait until you’re fully loaded into the game world before running any script.
  3. Open your executor app (Delta, Codex, Hydrogen, Wave, or any compatible one) and go to the script tab.
  4. Copy the loadstring code shown on this page and paste it into your executor’s script box, then press Execute.
  5. A GUI or confirmation should appear in-game — use it to turn on the features you want and adjust any settings.
Compatible Executors: Codex, Delta, Hydro, Potassium, Volt, Wave, Xeno
Script Code
-- [[ Rscripts Risk Notice ]]
-- This script is not verified by rscripts.net. Deal with caution.
--
-- Stay safe:
--   • Never log in on unofficial Roblox sites or lookalike domains.
--   • Real Roblox links use roblox.com (check the .com ending).
--   • Treat fake Roblox login / "claim reward" pages as phishing.
-- [[ End Rscripts Risk Notice ]]
local ENV = (typeof(getgenv) == "function" and getgenv()) or _G
if ENV.ElementalShowdownUnload then
	pcall(ENV.ElementalShowdownUnload)
end

local Config = {
	GuiName = "Elemental Showdown",
	SaveFolder = "ElementalShowdown",
	MenuKeybind = "RightControl",
	RemotePath = { "ReplicatedStorage", "EBShared", "Remotes" },
	RemoteNames = {
		ApplyDamage = "ApplyDamage",
		UseAbility = "UseAbility",
		UpdateAim = "UpdateAim",
		StatsUpdated = "StatsUpdated",
		AbilityFeedback = "AbilityFeedback",
	},
	RemoteBudget = 110,
	KillAura = {
		Damage = 1000,
		Radius = 250,
		HitsPerSecond = 9,
		MaxTargets = 10,
		ComboMax = 4,
		ScanInterval = 0.35,
	},
	Farm = {
		CastInterval = 0.4,
		RetryDelay = 2.5,
		StunBackoff = 1.2,
		Radius = 900,
		Charge = 0,
		ElementRefresh = 2,
	},
	Movement = {
		Speed = 60,
	},
	NoobFarm = {
		Offset = Vector3.new(0, 0, 4),
		TeleportInterval = 0.12,
		Tolerance = 7,
		RepickInterval = 0.4,
		SwitchDelay = 3.5,
	},
	ElementPoll = 1,
}

local function cloneService(instance)
	if typeof(cloneref) == "function" then
		local ok, result = pcall(cloneref, instance)
		if ok and result then
			return result
		end
	end
	return instance
end

local Players = cloneService(game:GetService("Players"))
local RunService = cloneService(game:GetService("RunService"))
local UserInputService = cloneService(game:GetService("UserInputService"))
local ReplicatedStorage = cloneService(game:GetService("ReplicatedStorage"))
local Workspace = game:GetService("Workspace")

local LocalPlayer = Players.LocalPlayer
local tableInsert = table.insert
local tableClear = table.clear
local clock = os.clock
local jumpingState = Enum.HumanoidStateType.Jumping

local State = { KillAura = false, AutoFarm = false, Speed = false, InfJump = false, NoobFarm = false }
local Connections = {}
local targets = {}
local hitClock = {}
local remoteCache = {}
local abilityReady = {}
local abilityIds = {}
local Character, Root, Humanoid
local comboIndex = 1
local lastScan = 0
local lastCast = 0
local lastElementCheck = 0
local lastElementPoll = 0
local hotbarConnections = {}
local stunnedUntil = 0
local abilityCursor = 1
local budgetWindow = 0
local budgetUsed = 0
local activeElement = "unknown"
local magicData
local Library
local focusPlayer
local playerLookup = {}
local deadUntil = {}
local currentNoob
local lastNoobPick = 0
local lastTeleport = 0
local refreshPlayerList

local function track(connection)
	if connection then
		tableInsert(Connections, connection)
	end
	return connection
end

local remotesFolder

local function resolveRemotes()
	if remotesFolder and remotesFolder.Parent then
		return remotesFolder
	end
	local path = Config.RemotePath
	local node = game:GetService(path[1])
	for index = 2, #path do
		if not node then
			return nil
		end
		local child = node:FindFirstChild(path[index])
		if not child then
			local ok, waited = pcall(node.WaitForChild, node, path[index], 5)
			child = ok and waited or nil
		end
		node = child
	end
	remotesFolder = node
	return node
end

local function getRemote(key)
	local name = Config.RemoteNames[key] or key
	local cached = remoteCache[name]
	if cached and cached.Parent then
		return cached
	end
	local folder = resolveRemotes()
	local found = folder and folder:FindFirstChild(name) or nil
	remoteCache[name] = found
	return found
end

local function takeBudget()
	local now = clock()
	if now - budgetWindow >= 1 then
		budgetWindow = now
		budgetUsed = 0
	end
	if budgetUsed >= Config.RemoteBudget then
		return false
	end
	budgetUsed += 1
	return true
end

local function fire(key, ...)
	local remote = getRemote(key)
	if not remote or not takeBudget() then
		return false
	end
	local args = table.pack(...)
	return (pcall(function()
		remote:FireServer(table.unpack(args, 1, args.n))
	end))
end

local function refreshCharacter(character)
	Character = character or LocalPlayer.Character
	Root = Character and (Character:FindFirstChild("HumanoidRootPart") or Character.PrimaryPart) or nil
	Humanoid = Character and Character:FindFirstChildOfClass("Humanoid") or nil
end

refreshCharacter()

local function loadMagicData()
	if magicData ~= nil then
		return magicData
	end
	local shared = ReplicatedStorage:FindFirstChild("EBShared")
	local module = shared and shared:FindFirstChild("MagicData")
	if not module then
		magicData = false
		return false
	end
	local ok, result = pcall(require, module)
	magicData = (ok and typeof(result) == "table") and result or false
	return magicData
end

local function maxCharge()
	local data = loadMagicData()
	if data and typeof(data.Config) == "table" and typeof(data.Config.MaxChargeTime) == "number" then
		return data.Config.MaxChargeTime
	end
	return Config.Farm.Charge
end

local function hotbarAbilityIds()
	local collected = {}
	local gui = LocalPlayer:FindFirstChild("PlayerGui")
	local hud = gui and gui:FindFirstChild("EB_HUD")
	local hotbar = hud and hud:FindFirstChild("Hotbar")
	if not hotbar then
		return collected
	end
	local seen = {}
	for index = 1, 8 do
		local slot = hotbar:FindFirstChild("Slot" .. tostring(index))
		if slot then
			local id = slot:GetAttribute("abId")
			if typeof(id) == "string" and id ~= "" and not seen[id] then
				seen[id] = true
				tableInsert(collected, id)
			end
		end
	end
	return collected
end

local function looksLikeAbility(value)
	if typeof(value) ~= "table" then
		return false
	end
	return value.damage ~= nil or value.cooldown ~= nil or value.unlockLevel ~= nil or value.range ~= nil
end

local function magicDataAbilityIds(element)
	local data = loadMagicData()
	if not data or typeof(element) ~= "string" then
		return {}
	end
	local lowered = string.lower(element)
	local node
	local function scan(container)
		if typeof(container) ~= "table" then
			return
		end
		for key, value in pairs(container) do
			if typeof(key) == "string" and typeof(value) == "table" and string.lower(key) == lowered then
				node = value
				return
			end
		end
	end
	scan(data)
	if not node then
		scan(data.Elements or data.Magics or data.magics or data.Magic)
	end
	local collected = {}
	if typeof(node) == "table" then
		local pool = node.Abilities or node.abilities or node
		if typeof(pool) == "table" then
			for key, value in pairs(pool) do
				if typeof(key) == "string" and looksLikeAbility(value) then
					tableInsert(collected, key)
				end
			end
		end
	end
	table.sort(collected)
	return collected
end

local function sameList(a, b)
	if #a ~= #b then
		return false
	end
	for index = 1, #a do
		if a[index] ~= b[index] then
			return false
		end
	end
	return true
end

local function setAbilityIds(list)
	if #list == 0 or sameList(list, abilityIds) then
		return
	end
	abilityIds = list
	abilityCursor = 1
	tableClear(abilityReady)
end

local function elementFromAbilities()
	for _, id in ipairs(abilityIds) do
		local prefix = string.match(id, "^([%a]+)_")
		if prefix then
			local data = loadMagicData()
			if data then
				for key, value in pairs(data) do
					if typeof(key) == "string" and typeof(value) == "table" then
						local pool = value.Abilities or value.abilities or value
						if typeof(pool) == "table" and pool[id] ~= nil then
							return key
						end
					end
				end
			end
			return prefix
		end
	end
	return nil
end

local function refreshAbilities()
	local fromHotbar = hotbarAbilityIds()
	if #fromHotbar > 0 then
		setAbilityIds(fromHotbar)
		if activeElement == "unknown" then
			local guessed = elementFromAbilities()
			if guessed then
				activeElement = guessed
			end
		end
		return
	end
	if activeElement ~= "unknown" then
		setAbilityIds(magicDataAbilityIds(activeElement))
	end
end

local function bindHotbar()
	for _, connection in ipairs(hotbarConnections) do
		pcall(function()
			connection:Disconnect()
		end)
	end
	tableClear(hotbarConnections)
	local gui = LocalPlayer:FindFirstChild("PlayerGui")
	local hud = gui and gui:FindFirstChild("EB_HUD")
	local hotbar = hud and hud:FindFirstChild("Hotbar")
	if not hotbar then
		return false
	end
	local function watchSlot(slot)
		if slot:IsA("GuiObject") or slot:IsA("Frame") then
			tableInsert(hotbarConnections, slot:GetAttributeChangedSignal("abId"):Connect(refreshAbilities))
		end
	end
	for _, slot in ipairs(hotbar:GetChildren()) do
		watchSlot(slot)
	end
	tableInsert(hotbarConnections, hotbar.ChildAdded:Connect(function(slot)
		watchSlot(slot)
		task.defer(refreshAbilities)
	end))
	for _, connection in ipairs(hotbarConnections) do
		track(connection)
	end
	return true
end

local function setElement(element)
	if typeof(element) ~= "string" or element == "" then
		return
	end
	if element ~= activeElement then
		activeElement = element
		tableClear(abilityReady)
	end
	refreshAbilities()
end

local stats = getRemote("StatsUpdated")
if stats then
	track(stats.OnClientEvent:Connect(function(payload)
		if typeof(payload) == "table" then
			setElement(payload.active or payload.Active or payload.element)
		end
	end))
end

local feedback = getRemote("AbilityFeedback")
if feedback then
	track(feedback.OnClientEvent:Connect(function(abilityId, ok, cooldown, status)
		local now = clock()
		if typeof(abilityId) == "string" then
			if ok == true and typeof(cooldown) == "number" and cooldown > 0 then
				abilityReady[abilityId] = now + cooldown
			elseif ok == false then
				abilityReady[abilityId] = now + Config.Farm.RetryDelay
			end
		end
		if status == "stunned" then
			stunnedUntil = now + Config.Farm.StunBackoff
		end
	end))
end

local hotbarBound = bindHotbar()
refreshAbilities()

task.spawn(function()
	for _ = 1, 40 do
		if #abilityIds > 0 and activeElement ~= "unknown" then
			break
		end
		if not hotbarBound then
			hotbarBound = bindHotbar()
		end
		refreshAbilities()
		task.wait(0.5)
	end
end)

local function considerModel(model, seen)
	if seen[model] or model == Character or not model:IsA("Model") then
		return
	end
	local humanoid = model:FindFirstChildOfClass("Humanoid")
	if not humanoid or humanoid.Health <= 0 then
		return
	end
	local root = model:FindFirstChild("HumanoidRootPart") or model.PrimaryPart
	if not root then
		return
	end
	seen[model] = true
	tableInsert(targets, { humanoid = humanoid, root = root, model = model })
end

local function scanTargets(now)
	if now - lastScan < Config.KillAura.ScanInterval then
		return
	end
	lastScan = now
	tableClear(targets)
	local seen = {}
	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= LocalPlayer and player.Character then
			considerModel(player.Character, seen)
		end
	end
	for _, child in ipairs(Workspace:GetChildren()) do
		if child:IsA("Model") then
			considerModel(child, seen)
		elseif child:IsA("Folder") then
			for _, nested in ipairs(child:GetChildren()) do
				if nested:IsA("Model") then
					considerModel(nested, seen)
				end
			end
		end
	end
end

local function runKillAura(now, origin)
	local settings = Config.KillAura
	local interval = 1 / settings.HitsPerSecond
	local used = 0
	for _, entry in ipairs(targets) do
		if used >= settings.MaxTargets then
			break
		end
		local root = entry.root
		if root.Parent and entry.humanoid.Health > 0 and (root.Position - origin).Magnitude <= settings.Radius then
			local last = hitClock[entry.humanoid] or 0
			if now - last >= interval then
				if fire("ApplyDamage", entry.humanoid, settings.Damage, comboIndex, root.Position) then
					hitClock[entry.humanoid] = now
					comboIndex += 1
					if comboIndex > settings.ComboMax then
						comboIndex = 1
					end
					used += 1
				end
			end
		end
	end
end

local function nearestTarget(origin)
	local best, bestDistance
	for _, entry in ipairs(targets) do
		if entry.root.Parent and entry.humanoid.Health > 0 then
			local distance = (entry.root.Position - origin).Magnitude
			if distance <= Config.Farm.Radius and (not bestDistance or distance < bestDistance) then
				best = entry
				bestDistance = distance
			end
		end
	end
	return best
end

local function nextReadyAbility(now)
	local count = #abilityIds
	if count == 0 then
		return nil
	end
	for _ = 1, count do
		local id = abilityIds[abilityCursor]
		abilityCursor += 1
		if abilityCursor > count then
			abilityCursor = 1
		end
		local readyAt = abilityReady[id]
		if not readyAt or now >= readyAt then
			return id
		end
	end
	return nil
end

local function runAutoFarm(now, origin)
	if now - lastElementCheck >= Config.Farm.ElementRefresh then
		lastElementCheck = now
		refreshAbilities()
	end
	if now < stunnedUntil or now - lastCast < Config.Farm.CastInterval then
		return
	end
	local id = nextReadyAbility(now)
	if not id then
		return
	end
	local focus = nearestTarget(origin)
	local aim = focus and CFrame.new(origin, focus.root.Position) or (Root and Root.CFrame)
	if not aim then
		return
	end
	lastCast = now
	abilityReady[id] = now + Config.Farm.RetryDelay
	fire("UpdateAim", aim)
	fire("UseAbility", id, aim, maxCharge())
end

local function characterRoot(player)
	local character = player.Character
	if not character then
		return nil
	end
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	local root = character:FindFirstChild("HumanoidRootPart") or character.PrimaryPart
	if humanoid and root and humanoid.Health > 0 then
		return root
	end
	return nil
end

local function pickNoob(now, origin)
	if focusPlayer then
		if focusPlayer.Parent and characterRoot(focusPlayer) then
			return focusPlayer
		end
		return nil
	end
	local best, bestDistance
	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= LocalPlayer and (deadUntil[player] or 0) <= now then
			local root = characterRoot(player)
			if root then
				local distance = (root.Position - origin).Magnitude
				if not bestDistance or distance < bestDistance then
					best = player
					bestDistance = distance
				end
			end
		end
	end
	return best
end

local function runNoobFarm(now, origin)
	if not Root or not Humanoid or Humanoid.Health <= 0 then
		return
	end
	local settings = Config.NoobFarm
	if currentNoob and (not currentNoob.Parent or not characterRoot(currentNoob)) then
		deadUntil[currentNoob] = now + settings.SwitchDelay
		currentNoob = nil
	end
	if not currentNoob or now - lastNoobPick >= settings.RepickInterval then
		lastNoobPick = now
		local picked = pickNoob(now, origin)
		if picked then
			currentNoob = picked
		end
	end
	if not currentNoob then
		return
	end
	local root = characterRoot(currentNoob)
	if not root then
		return
	end
	if now - lastTeleport < settings.TeleportInterval then
		return
	end
	local goal = root.CFrame * CFrame.new(settings.Offset)
	if (Root.Position - goal.Position).Magnitude <= settings.Tolerance then
		return
	end
	lastTeleport = now
	Root.CFrame = goal
	Root.AssemblyLinearVelocity = Vector3.zero
end

local function applySpeed()
	if not Humanoid or Humanoid.Health <= 0 then
		return
	end
	if Humanoid.WalkSpeed ~= Config.Movement.Speed then
		Humanoid.WalkSpeed = Config.Movement.Speed
	end
end

local function restoreSpeed()
	if not Humanoid then
		return
	end
	local base = Humanoid:GetAttribute("EBBaseSpeed")
	Humanoid.WalkSpeed = (typeof(base) == "number" and base > 0) and base or 18
end

track(RunService.PostSimulation:Connect(function()
	local now = clock()
	if not Root or not Root.Parent or not Humanoid or not Humanoid.Parent then
		refreshCharacter()
	end
	if State.Speed then
		applySpeed()
	end
	if now - lastElementPoll >= Config.ElementPoll then
		lastElementPoll = now
		if not hotbarBound then
			hotbarBound = bindHotbar()
		end
		refreshAbilities()
	end
	if not Root then
		return
	end
	if not (State.KillAura or State.AutoFarm or State.NoobFarm) then
		return
	end
	if State.NoobFarm then
		runNoobFarm(now, Root.Position)
	end
	local origin = Root.Position
	scanTargets(now)
	if State.KillAura then
		runKillAura(now, origin)
	end
	if State.AutoFarm then
		runAutoFarm(now, origin)
	end
end))

track(UserInputService.JumpRequest:Connect(function()
	if State.InfJump and Humanoid and Humanoid.Health > 0 then
		Humanoid:ChangeState(jumpingState)
	end
end))

track(LocalPlayer.CharacterAdded:Connect(function(character)
	task.defer(function()
		refreshCharacter(character)
		tableClear(hitClock)
		tableClear(abilityReady)
		stunnedUntil = 0
		refreshAbilities()
	end)
end))

local repo = "https://raw.githubusercontent.com/deividcomsono/Obsidian/main/"
Library = loadstring(game:HttpGet(repo .. "Library.lua"))()
local SaveManager = loadstring(game:HttpGet(repo .. "addons/SaveManager.lua"))()
local ThemeManager = loadstring(game:HttpGet(repo .. "addons/ThemeManager.lua"))()

Library.ForceCheckbox = false
Library.ShowToggleFrameInKeybinds = true

local Window = Library:CreateWindow({
	Title = Config.GuiName,
	Footer = Config.GuiName,
	AutoShow = true,
	NotifySide = "Right",
	ShowCustomCursor = false,
})

local CombatTab = Window:AddTab("Combat", "swords")
local FarmTab = Window:AddTab("Farm", "sprout")
local NoobTab = Window:AddTab("Farm Noobs", "crosshair")
local MovementTab = Window:AddTab("Movement", "footprints")
local SettingsTab = Window:AddTab("Settings", "sliders-horizontal")

local AuraBox = CombatTab:AddLeftGroupbox("Kill Aura", "swords")

AuraBox:AddToggle("KillAura", {
	Text = "Kill Aura",
	Default = false,
	Callback = function(value)
		State.KillAura = value
		if not value then
			tableClear(hitClock)
			tableClear(targets)
			comboIndex = 1
			lastScan = 0
		end
	end,
})

local FarmBox = FarmTab:AddLeftGroupbox("Auto Farm", "sprout")

FarmBox:AddToggle("AutoFarmLevel", {
	Text = "Auto Farm LVL",
	Default = false,
	Callback = function(value)
		State.AutoFarm = value
		if value then
			refreshAbilities()
			lastCast = 0
			lastElementCheck = 0
		else
			stunnedUntil = 0
		end
	end,
})

local NoobBox = NoobTab:AddLeftGroupbox("Farm Noobs", "crosshair")

NoobBox:AddToggle("NoobFarm", {
	Text = "Auto TP Players",
	Default = false,
	Callback = function(value)
		State.NoobFarm = value
		if value then
			currentNoob = nil
			lastNoobPick = 0
			lastTeleport = 0
			tableClear(deadUntil)
		else
			currentNoob = nil
		end
	end,
})

NoobBox:AddDropdown("FocusPlayer", {
	Text = "Focus player",
	Values = {},
	AllowNull = true,
	Callback = function(value)
		focusPlayer = value and playerLookup[value] or nil
		currentNoob = nil
		lastNoobPick = 0
	end,
})

NoobBox:AddButton("Refresh players", function()
	refreshPlayerList()
end)

refreshPlayerList = function()
	local values = {}
	tableClear(playerLookup)
	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= LocalPlayer then
			local label = player.DisplayName
			if label ~= player.Name then
				label = label .. " (@" .. player.Name .. ")"
			end
			playerLookup[label] = player
			tableInsert(values, label)
		end
	end
	table.sort(values)
	pcall(function()
		local option = Library.Options.FocusPlayer
		option:SetValues(values)
		if option.Value and not playerLookup[option.Value] then
			option:SetValue(nil)
		end
	end)
end

refreshPlayerList()

track(Players.PlayerAdded:Connect(function()
	task.defer(refreshPlayerList)
end))

track(Players.PlayerRemoving:Connect(function(player)
	if player == focusPlayer then
		focusPlayer = nil
	end
	if player == currentNoob then
		currentNoob = nil
	end
	deadUntil[player] = nil
	task.defer(refreshPlayerList)
end))

local MovementBox = MovementTab:AddLeftGroupbox("Movement", "footprints")

MovementBox:AddToggle("SpeedEnabled", {
	Text = "Speed",
	Default = false,
	Callback = function(value)
		State.Speed = value
		if not value then
			restoreSpeed()
		end
	end,
})

MovementBox:AddSlider("SpeedValue", {
	Text = "Speed value",
	Default = 60,
	Min = 18,
	Max = 250,
	Rounding = 0,
	Callback = function(value)
		Config.Movement.Speed = value
	end,
})

MovementBox:AddToggle("InfJump", {
	Text = "Infinite Jump",
	Default = false,
	Callback = function(value)
		State.InfJump = value
	end,
})

SaveManager:SetLibrary(Library)
SaveManager:IgnoreThemeSettings()
SaveManager:SetFolder(Config.SaveFolder)

ThemeManager:SetLibrary(Library)
ThemeManager:SetFolder(Config.SaveFolder)

local ConfigGroupbox = SettingsTab:AddRightGroupbox("Configuration", "folder-cog")

ConfigGroupbox:AddInput("SaveManager_ConfigName", {
	Text = "Config name",
	Placeholder = "My Config",
})

ConfigGroupbox:AddButton("Create config", function()
	local name = Library.Options.SaveManager_ConfigName.Value
	if name:gsub(" ", "") == "" then
		Library:Notify("Invalid config name (empty)", 2)
		return
	end
	local success, err = SaveManager:Save(name)
	if not success then
		Library:Notify("Failed to create config: " .. err)
		return
	end
	Library:Notify(string.format("Created config %q", name))
	Library.Options.SaveManager_ConfigList:SetValues(SaveManager:RefreshConfigList())
	Library.Options.SaveManager_ConfigList:SetValue(nil)
end)

ConfigGroupbox:AddDivider()

ConfigGroupbox:AddDropdown("SaveManager_ConfigList", {
	Text = "Config list",
	Values = SaveManager:RefreshConfigList(),
	AllowNull = true,
})

ConfigGroupbox:AddButton("Load config", function()
	local name = Library.Options.SaveManager_ConfigList.Value
	local success, err = SaveManager:Load(name)
	if not success then
		Library:Notify("Failed to load config: " .. err)
		return
	end
	Library:Notify(string.format("Loaded config %q", name))
end)

ConfigGroupbox:AddButton("Overwrite config", function()
	local name = Library.Options.SaveManager_ConfigList.Value
	local success, err = SaveManager:Save(name)
	if not success then
		Library:Notify("Failed to overwrite config: " .. err)
		return
	end
	Library:Notify(string.format("Overwrote config %q", name))
end)

ConfigGroupbox:AddButton("Delete config", function()
	local name = Library.Options.SaveManager_ConfigList.Value
	local success, err = SaveManager:Delete(name)
	if not success then
		Library:Notify("Failed to delete config: " .. err)
		return
	end
	Library:Notify(string.format("Deleted config %q", name))
	Library.Options.SaveManager_ConfigList:SetValues(SaveManager:RefreshConfigList())
	Library.Options.SaveManager_ConfigList:SetValue(nil)
end)

ConfigGroupbox:AddButton("Refresh list", function()
	Library.Options.SaveManager_ConfigList:SetValues(SaveManager:RefreshConfigList())
	Library.Options.SaveManager_ConfigList:SetValue(nil)
end)

local AutoloadLabel = ConfigGroupbox:AddLabel("Current autoload config: " .. SaveManager:GetAutoloadConfig(), true)

ConfigGroupbox:AddButton("Set as autoload", function()
	local name = Library.Options.SaveManager_ConfigList.Value
	local success, err = SaveManager:SaveAutoloadConfig(name)
	if not success then
		Library:Notify("Failed to set autoload config: " .. err)
		return
	end
	Library:Notify(string.format("Set %q to auto load", name))
	AutoloadLabel:SetText("Current autoload config: " .. name)
end)

ConfigGroupbox:AddButton("Reset autoload", function()
	local success, err = SaveManager:DeleteAutoLoadConfig()
	if not success then
		Library:Notify("Failed to reset autoload config: " .. err)
		return
	end
	Library:Notify("Set autoload to none")
	AutoloadLabel:SetText("Current autoload config: none")
end)

local MenuGroup = SettingsTab:AddLeftGroupbox("Menu", "wrench")

MenuGroup:AddLabel("Menu bind"):AddKeyPicker("MenuKeybind", {
	Default = Config.MenuKeybind,
	NoUI = true,
	Text = "Menu keybind",
})

MenuGroup:AddButton("Unload", function()
	Library:Unload()
end)

SaveManager:SetIgnoreIndexes({ "SaveManager_ConfigList", "SaveManager_ConfigName", "MenuKeybind", "FocusPlayer" })

Library.ToggleKeybind = Library.Options.MenuKeybind
ThemeManager:ApplyToTab(SettingsTab)

SaveManager:LoadAutoloadConfig()

local function cleanup()
	for key in pairs(State) do
		State[key] = false
	end
	restoreSpeed()
	for _, connection in ipairs(Connections) do
		pcall(function()
			connection:Disconnect()
		end)
	end
	tableClear(Connections)
	tableClear(targets)
	tableClear(hitClock)
	tableClear(abilityReady)
	tableClear(deadUntil)
	tableClear(playerLookup)
	focusPlayer = nil
	currentNoob = nil
	tableClear(hotbarConnections)
	tableClear(remoteCache)
	remotesFolder = nil
	ENV.ElementalShowdownUnload = nil
end

ENV.ElementalShowdownUnload = function()
	pcall(cleanup)
	pcall(function()
		Library:Unload()
	end)
end

Library:OnUnload(function()
	cleanup()
end)
💬 Comments 0
You

No comments yet. Be the first!