The following code works perfectly:

```
func(k_) :=
func(k) =
NDSolve({
y'(t) == y(t) - z(t),
z'(t) == y(t) - k*z(t),
y(0) == 3, z(0) == 0},
{y, z}, {t, 0, 2})
Manipulate(Plot(({
y(tt) /. func(k)
}),
{tt, 0, 2},
PlotLegends -> {y}),
{k, 0, 3, 0.5}
)
```

is a minimized version of the 1st answer of this post.

The problematic code:

```
func(k_) :=
NDSolve({
y'(t, x) == y(t, x) - z(t, x),
z'(t, x) == y(t, x) - k*z(t, x),
y(0, x) == 3, z(0, x) == 0,
y(t, -2) == 0, z(t, -2) == 0,
y(t, 2) == 1, z(t, 2) == 0
},
{y, z}, {t, 1, 5}, {x, -2, 2})
Manipulate(
DensityPlot(
({
y(tt, xx) /. func(l)
}),
{tt, 0, 5}, {xx, -2, 2}
),
{l, 0, 3, 0.5}
)
```

“{func(0)} is neither a list of replacement rules nor a valid

dispatch table, and so cannot be used for replacing”

error keeps showing up when I try to change “the working” code as the “problematic” one.

There are many posts about this error here, I have read a plenty of them and tried their solutions but those did not solve my problem. I would appreciate if someone would points out

- why the error happened
- how to fix it?