Skip to content
RustPluginGenerator
CS0428Oxide + Carbon

Fix CS0428: Cannot convert method group 'MaxHealth' to non-delegate type 'float' (Oxide)

CS0428 means you used a method name as if it were a value. In Rust plugins this is almost always BaseCombatEntity.MaxHealth, which is a method, so it must be written MaxHealth() with parentheses.

Server console
Error while compiling HealthBar:
[1] Cannot convert method group 'MaxHealth' to non-delegate type 'float'. Did you intend to invoke the method? at 24:32

Why it happens

In Rust's API, health is a public field (entity.health) while the maximum health is exposed through a method, MaxHealth(). Writing entity.MaxHealth (no parentheses) hands the compiler a method group instead of a float, and Roslyn reports CS0428 because it cannot convert a method group to float. The same pattern exists for other members that look like properties: player.IsDead, container.IsFull, player.IsConnected, or your own helper methods declared as float MaxHealth() but referenced as MaxHealth. The compiler error line and column point at the exact spot, usually a string interpolation, a comparison, or a math expression such as player.health / player.MaxHealth. Carbon reports the same CS0428 because it uses the same C# compiler on the same file.

How to fix it

  1. Read the at <line>:<column> part of the error; open that file at that line. 2. Find the member name mentioned in the message (MaxHealth in this case) and check whether it is declared with parentheses in the API or in your own class. 3. Add the call parentheses: MaxHealth becomes MaxHealth(), IsDead becomes IsDead(). 4. Recompile by saving the file or running oxide.reload HealthBar. 5. Confirm the fix: the console prints Loaded plugin HealthBar v1.0.0 by RustPluginGenerator and no Error while compiling block. If the same line now reports CS1061 or CS7036, the member name or arguments are wrong, not the invocation syntax.

Before and after

BeforeFails
using System.Collections.Generic;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("HealthBar", "RustPluginGenerator", "1.0.0")]
    [Description("Shows a player's health percentage in chat")]
    public class HealthBar : RustPlugin
    {
        [ChatCommand("hp")]
        private void CmdHp(BasePlayer player, string command, string[] args)
        {
            if (player == null)
            {
                return;
            }

            float percent = GetPercent(player);
            SendReply(player, "Health: " + player.health + " / " + player.MaxHealth + " (" + percent + "%)");
        }

        private float GetPercent(BasePlayer player)
        {
            float max = player.MaxHealth;
            if (max <= 0f)
            {
                return 0f;
            }

            return Mathf.Round(player.health / max * 100f);
        }
    }
}
AfterFixed
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("HealthBar", "RustPluginGenerator", "1.0.0")]
    [Description("Shows a player's health percentage in chat")]
    public class HealthBar : RustPlugin
    {
        [ChatCommand("hp")]
        private void CmdHp(BasePlayer player, string command, string[] args)
        {
            if (player == null)
            {
                return;
            }

            float percent = GetPercent(player);
            SendReply(player, "Health: " + player.health + " / " + player.MaxHealth() + " (" + percent + "%)");
        }

        private float GetPercent(BasePlayer player)
        {
            float max = player.MaxHealth();
            if (max <= 0f)
            {
                return 0f;
            }

            return Mathf.Round(player.health / max * 100f);
        }
    }
}

FAQ

Why does `health` work without parentheses but `MaxHealth` does not?

BaseCombatEntity.health is a public field holding a float, so it can be read and written directly. MaxHealth() is a method that computes the maximum from the entity's state, so it must be invoked. Mixing the two up is the most common source of CS0428 in Rust plugins.

The error says 'Did you intend to invoke the method?'. Is that always the fix?

Almost always. The compiler suggests it because the target type is float and only a call returning float fits. The exception would be passing the method as a delegate, but Oxide hook parameters never expect a delegate, so in plugin code adding () is correct.

Can CS0428 appear for a method I wrote myself?

Yes. If you declare private float GetPercent(...) and later write value * GetPercent, the compiler sees a method group. The fix is identical: call it with the required arguments. Check the signature for parameter count, since a missing argument produces CS7036 instead.

Does Carbon show the same error differently?

Carbon compiles the same C# file with the same Roslyn diagnostics but formats the output with the CS code and source line included. The cause and fix are unchanged; only the log layout differs from Oxide's numbered [1] ... at line:column format.

Different error?

Paste the full console output and get the cause and a fix in plain English.

Open the error explainer

Skip the debugging

Generated plugins are compiled before you get them, and compiler errors are fixed automatically.

Generate a plugin

2 free plugins a month, no card.

Last updated Oct 26, 2026.

Get plugins that compile first time

Generate