codeAPI Reference

s&box IToolgunEvent: Toolgun selection interception

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

IToolgunEvent Interface API Reference

IToolgunEvent is an interface for Components that want to intercept toolgun selection attempts. Implement to allow or reject toolgun interactions.

Type Signature

CSHARP
public interface IToolgunEvent : ISceneEvent<IToolgunEvent>
{
    public class SelectEvent
    {
        public Connection User { get; init; }
        public bool Cancelled { get; set; }
    }

    void OnToolgunSelect(SelectEvent e);
}

Event Data

SelectEvent

Methods

OnToolgunSelect(SelectEvent e)

Called when a player attempts to select this object with the toolgun. Set SelectEvent.Cancelled to true to reject the selection.

Usage

CSHARP
public class MyProtectedProp : Component, IToolgunEvent
{
    public void OnToolgunSelect(IToolgunEvent.SelectEvent e)
    {
        // Only allow the owner to use tools
        var ownable = GetComponent<Ownable>();
        if (ownable?.Owner != e.User)
        {
            e.Cancelled = true;
        }
    }
}

Notes

  • Implements ISceneEvent for scene-wide event broadcasting
  • Used by Ownable component for prop protection
  • Cancelled property prevents the toolgun selection
  • User is the Connection attempting the toolgun interaction
  • Event is broadcast to all IToolgunEvent components on the GameObject
  • Works with all toolgun modes (weld, balloon, thruster, etc.)
Was this helpful?