So I have no problem getting my character to move one direction. What this code is supposed to do is loop him back and forth between x cords. of 1 and 400. But it is causing a crash. I think it may be from declaring moveRight being False then calling it right toward the end.
If anyone can tell me what I’m doing wrong here I would really appreciate it, I’ve been working on it all day.
[code]
local moveRight = true
local function move (event) – Moves and updates the Player’s movement
if moveRight == true then
if turtle.x < 400 then
turtle.applyForce( 8, 0)
elseif turtle.x>400 then
moveRight = false
end
elseif moveRight == false then
if turtle.x>1 then
turtle.applyForce( -8, 0 )
elseif turtle.x<1 then
moveRight = true
end
end
end
Runtime:addEventListener(“enterFrame”, move)
[/code] [import]uid: 42079 topic_id: 8094 reply_id: 308094[/import]