Hello, the custom npc I'm doing has a small problem that I don't know how to solve, it was supposed to move back and forth, without having to change the v.direction (similar to birdo) using a timer as a reference, but even though I put the code below, it only walks in one direction, if someone could help me I would be grateful
if player.x < v.x then
v.direction = -1
elseif player.x > v.x then
v.direction = 1
end
if data.shoottimer > 80 then
v.speedX = v.direction * 0.65
elseif data.shoottimer < 80 then
v.speedX = -v.direction * 0.65
end