I am currently making a 2D game with grid movement, but when I try to use tweens I always just come out confused, so that's why the issue might be painfully obvious. I cannot find a way to,

  1. Make a variable that equals 0 (on first movement) not come back as null.
  2. If there's a better way to use/make tweens.

This is the code

extends CharacterBody2D

var x = 0
var y = 0
var speed = 25

func _input(event):
	if event.is_action_pressed("right"):
		x = x + speed
		position.x = x
		var xprevpos = position.x - speed
		position.y = y
		var yprevpos = position.y - speed
		var tween = create_tween()
		tween.tween_property(xprevpos,"position",x,.2)

I see why you're confused. Tweens are built in to allow you to interpolate from x1 to x2 without having to bother keeping track of delta time and such inside the sensitive _process functions. A tween is something you just setup and let it do it's own thing; the way you're using it equates to setting it up as long as the player is trying to move.

Example of where I would use a tween:

	var tween : Tween = get_child(0) # get my Tween node
	tween.interpolate_property(self, "zoom", zoom, zoomLevel, 0.7, Tween.TRANS_CUBIC) # use it zoom in or out smoothly
	tween.start()

This tween code facilitates smooth zoom in/ zoom out movement. I only have to call it once and it runs over many frames.

Places I wouldn't use a tween:
Anywhere I need frame to frame control over the variable (like in player movement script). Why? You know x1 (current position) but you don't really know x2.

The effect I am trying to achieve is a smooth motion between x1 and x2, the x2 in this case is speed (25) + x1 (0) is there a way to achieve this with tweens or is this a job for something else?