How to make the player's foundation indestructible when destroying the player's building?Solved
private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
	if (entity is BuildingBlock)
	{
		var block = entity as BuildingBlock;
		Message(info.InitiatorPlayer,block.ShortPrefabName);
	}
	if (entity.OwnerID != info.InitiatorPlayer.userID)
	{
		if (entity.ShortPrefabName.ToLower().Contains("foundations"))
		{
			Message(info.InitiatorPlayer, entity.ShortPrefabName);
		}
	}
}​

I tried to use the OnEntityTakeDamage event to get whether the short name of the foundation contains the field "foundations" to judge, but it doesn't seem to work when I use it.
Neither of the above two judgments gave the proper response. How can I correct it?

It's been solved, it's my own typo, sorry

its  "foundation"  without the 's'

        void OnEntityTakeDamage(BuildingBlock entity, HitInfo info)
        {
            if (entity.OwnerID != info.InitiatorPlayer.userID)
            {
                if (entity.ShortPrefabName.ToLower().Contains("foundation"))
                {
                    Puts($"Foundation {info.InitiatorPlayer}  {entity.ShortPrefabName}");
                    info.damageTypes.ScaleAll(0);
                }
            }
        }​
Iq21dlQIlYnlQTl.jpg Lorenzo

its  "foundation"  without the 's'

        void OnEntityTakeDamage(BuildingBlock entity, HitInfo info)
        {
            if (entity.OwnerID != info.InitiatorPlayer.userID)
            {
                if (entity.ShortPrefabName.ToLower().Contains("foundation"))
                {
                    Puts($"Foundation {info.InitiatorPlayer}  {entity.ShortPrefabName}");
                    info.damageTypes.ScaleAll(0);
                }
            }
        }​

thank you for your help!

Locked automatically