Having Trouble With ISystem

Hey, I’ve wrote some basic code that doesn’t seem to be working
It keeps giving the following error:

CS1654 Cannot modify members of ‘localTransform’ because it is a ‘foreach iteration variable’

The code:

using Unity.Entities;
using Unity.Transforms;
using Unity.Mathematics;

public struct MoveEntities : ISystem
{
    public void OnUpdate()
    {
        float deltaTime = SystemAPI.Time.DeltaTime;

        foreach (LocalTransform localTransform in SystemAPI.Query<LocalTransform>())
        {
            localTransform.Position += new float3(0, 0, 0) * deltaTime;
        }
    }
}

You need to use RefRW so it’s modifiable Iterate over component data with SystemAPI.Query | Entities | 1.0.11

I now think this guy is a bot, posting outputs from some ai generator our way.
Code doesn’t make any sense, sentences are fishy + got 2 system warnings on him which I ignored far too hastily.

using Unity.Entities;
using Unity.Transforms;
using Unity.Mathematics;

public struct MoveEntities : ISystem
{
    public void OnUpdate()
    {
        float deltaTime = SystemAPI.Time.DeltaTime;

        // Create a copy of the LocalTransform struct
        var localTransforms = SystemAPI.Query<LocalTransform>();

        // Iterate over the copy and modify the elements
        for (int i = 0; i < localTransforms.Length; i++)
        {
            var localTransform = localTransforms[i];

            // Modify the localTransform struct
            localTransform.Position += new float3(0, 0, 0) * deltaTime;

            // Assign the modified struct back to the collection
            localTransforms[i] = localTransform;
        }
    }
}

In the updated code, I replaced each loop with a for loop to have control over the index of the array. This allows us to modify the elements of the localTransforms array by making a copy, modifying the copy, and assigning it back to the array.

Make sure to use the appropriate API or library functions for modifying and accessing the collection of LocalTransform instances within Unity. Entities, as in the example above assumes a basic array structure for demonstration purposes.