local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local StarterGui = game:GetService("StarterGui") print("--- ЗАПУСК КОНТРОЛЛЕРА (v16: Mana Cost Display) ---") local player = Players.LocalPlayer local gui = script.Parent local hotbar = gui:WaitForChild("Hotbar") local menuFrame = gui:WaitForChild("AbilityMenu") local openMenuBtn = gui:WaitForChild("OpenMenuBtn") local AbilitiesFolder = ReplicatedStorage:WaitForChild("Abilities") -- ССЫЛКИ НА ПАНЕЛИ local leftPanel = menuFrame:WaitForChild("LeftPanel") local rightPanel = menuFrame:WaitForChild("RightPanel") local titleLabel = rightPanel:WaitForChild("TitleText") local descLabel = rightPanel:WaitForChild("DescText") -- [НОВОЕ] Ищем текст цены маны (создай его в GUI!) local costLabel = rightPanel:FindFirstChild("CostText") local resetButton = menuFrame:FindFirstChild("ResetButton") or leftPanel:FindFirstChild("ResetButton") or rightPanel:FindFirstChild("ResetButton") local menuButtonsMap = {} -- ============================================================== -- 1. ВИЗУАЛ (Таймер и Затемнение) -- ============================================================== local function PlayCooldownAnimation(slotBtn, duration) local cdFrame = slotBtn:FindFirstChild("CooldownOverlay") if not cdFrame then cdFrame = Instance.new("Frame"); cdFrame.Name = "CooldownOverlay"; cdFrame.Size = UDim2.new(1,0,1,0); cdFrame.BackgroundTransparency = 0.3; cdFrame.BackgroundColor3 = Color3.new(0,0,0); cdFrame.ZIndex=10; cdFrame.Parent = slotBtn local c = Instance.new("UICorner", cdFrame); c.CornerRadius = UDim.new(0,8) local t = Instance.new("TextLabel", cdFrame); t.Name="TimerText"; t.Size=UDim2.new(0.5,0,0.5,0); t.Position=UDim2.new(0.25,0,0.25,0); t.BackgroundTransparency=1; t.TextColor3=Color3.new(1,1,1); t.TextScaled=true; t.Font=Enum.Font.GothamBold; t.ZIndex=11 end local textLabel = cdFrame.TimerText; cdFrame.Visible = true task.spawn(function() local s = tick() while tick()-s < duration do local left = duration-(tick()-s) textLabel.Text = (left<1) and string.format("%.1f", left) or math.ceil(left) task.wait(0.1) end cdFrame.Visible = false end) end local function SetAbilityEquipped(abilityName, isEquipped) local btn = menuButtonsMap[abilityName] if btn then btn.ImageColor3 = isEquipped and Color3.new(0.4, 0.4, 0.4) or Color3.new(1, 1, 1) end end -- ============================================================== -- 2. СБРОС -- ============================================================== local currentLoadout = {} local cooldowns = {} if resetButton then resetButton.MouseButton1Click:Connect(function() for abilityName, _ in pairs(currentLoadout) do SetAbilityEquipped(abilityName, false) end currentLoadout = {} for _, child in pairs(hotbar:GetChildren()) do if child:IsA("ImageButton") or child:IsA("TextButton") then child.Image = "" local overlay = child:FindFirstChild("CooldownOverlay") if overlay then overlay.Visible = false end end end titleLabel.Text = "Выберите способность" descLabel.Text = "Нажмите на иконку слева..." if costLabel then costLabel.Text = "" end end) end -- ============================================================== -- 3. ЗАГРУЗКА -- ============================================================== openMenuBtn.MouseButton1Click:Connect(function() menuFrame.Visible = not menuFrame.Visible end) local AbilityModules = {} local selectedAbilityName = nil if costLabel then costLabel.Text = "" end -- Очищаем цену при старте for _, module in pairs(AbilitiesFolder:GetChildren()) do if module:IsA("ModuleScript") then local success, result = pcall(function() return require(module) end) if success then AbilityModules[module.Name] = result local btnName = module.Name .. "Icon" local btn = leftPanel:FindFirstChild(btnName) if btn then menuButtonsMap[module.Name] = btn btn.MouseButton1Click:Connect(function() selectedAbilityName = module.Name -- ОБНОВЛЯЕМ ИНФОРМАЦИЮ titleLabel.Text = result.Info.Name or module.Name descLabel.Text = result.Info.Description or "Нет описания" -- [НОВОЕ] Показываем цену маны if costLabel then local cost = result.Info.ManaCost or 0 costLabel.Text = "Мана: " .. cost -- Если мана бесплатная, можно писать "Бесплатно" if cost == 0 then costLabel.Text = "Мана: 0 (Бесплатно)" end end print("🔵 Инфо обновлено: " .. module.Name) end) end end end end -- ============================================================== -- 4. СЛОТЫ -- ============================================================== for _, child in pairs(hotbar:GetChildren()) do if child:IsA("ImageButton") or child:IsA("TextButton") then child.MouseButton1Click:Connect(function() if selectedAbilityName then local module = AbilityModules[selectedAbilityName] if not module or not module.Info then return end local oldAbility = currentLoadout[child.Name] if oldAbility then SetAbilityEquipped(oldAbility, false) end for slot, ability in pairs(currentLoadout) do if ability == selectedAbilityName then currentLoadout[slot] = nil local oldBtn = hotbar:FindFirstChild(slot) if oldBtn then oldBtn.Image = "" end end end currentLoadout[child.Name] = selectedAbilityName child.Image = module.Info.Icon SetAbilityEquipped(selectedAbilityName, true) selectedAbilityName = nil end end) end end -- ============================================================== -- 5. АКТИВАЦИЯ -- ============================================================== local ControllerAPI = {} function ControllerAPI.ShowNotification(text) StarterGui:SetCore("SendNotification", {Title = "Ability"; Text = text; Duration = 2;}) end local keyMap = { [Enum.KeyCode.E] = "Slot1", [Enum.KeyCode.R] = "Slot2", [Enum.KeyCode.X] = "Slot3", [Enum.KeyCode.F] = "Slot4", [Enum.KeyCode.V] = "Slot5", [Enum.KeyCode.C] = "Slot6" } UserInputService.InputBegan:Connect(function(input, gp) if gp then return end local slotName = keyMap[input.KeyCode] if slotName then local abilityName = currentLoadout[slotName] if abilityName and AbilityModules[abilityName] then local module = AbilityModules[abilityName] -- Проверка маны local char = player.Character if char then local currentMana = char:GetAttribute("Mana") or 0 local manaCost = module.Info.ManaCost or 0 if currentMana < manaCost then ControllerAPI.ShowNotification("Мана: " .. math.floor(currentMana) .. "/" .. manaCost) return end end local lastTime = cooldowns[abilityName] or 0 local cdTime = module.Info.Cooldown or 0 if tick() - lastTime < cdTime then return end local success = module.Activate(ControllerAPI) if success ~= false then cooldowns[abilityName] = tick() local slotBtn = hotbar:FindFirstChild(slotName) if slotBtn then PlayCooldownAnimation(slotBtn, cdTime) end end end end end)