Numbers 24:2, The Spirit of Elohim came upon him. We see from the Scriptures that the Spirit of YHVH can come on just about anyone, but this doesn’t mean that the Spirit dwells in them, leads them, or that such a person has a heart to love, serve and obey Elohim.
For example, the Spirit of Elohim came upon King Saul who prophesied (see 1 Sam 10:9–11; 19:20–24), but Saul didn’t serve YHVH with his whole heart and eventually became a murderous, apostate occultist.
Not only does the Bible warn us to beware of prophets who prophecy falsely (e.g. Deut 13:1–5; Jer 23:9–40; Ezek 13:2; 22:24; Isa 28:7; Matt 24:4–5; 2 Pet 2:1–3), but to beware false prophets or unrighteous individuals who YHVH may use to prophecy correctly—not because they are filled with the Spirit of Elohim, but simply because the Spirit of Elohim temporarily comes upon them to accomplish YHVH’s purposes.