how do i fix invalid call. nonexistent function 'interpolate_property' in base 'Nil'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DragonslayerGXZY

so ive been making fruit ninja because my school gave me the assigment to make fruit ninja and ive been getting this error that says invalid call. nonexistent function ‘interpolate_property’ in base ‘Nil’. and i dont know how to fix it. heres the code where the error is from. plz help this is due monday

for orange splat:

extends Sprite

onready var splat = $splat
onready var fade = $fade

func _ready():

# warning-ignore:function_conflicts_variable
func splat():
	var r = rand_range(1, 360)
	splat.interpolate_property(self, "scale", Vector2(.2,.2),Vector2(1,1) ,.3,Tween.TRANS_QUAD) #this is the code giving the problem
# warning-ignore:function_conflicts_variable
func fade():
	fade.interpolate_property(self, "modulate", Color(1,1,1,1), Color(1,1,1,0), 10,Tween.TRANS_QUAD)
func _on_fade_tween_all_completed():

orange code:

extends RigidBody2D

onready var tween = $Tween
onready var collision = $CollisionShape2D
onready var orangebottom = preload("res://orangebottom.tscn")
onready var orangetop = preload("res://orangetop.tscn")
onready var splat = preload("res://orangesplat.tscn")
func _process(delta):
	#area.disabled = true
	collision.disabled = true
func _ready():

func fly():
	var randomx = rand_range(550, 1000)
	var randomy = rand_range(600, 900)
	var r = rand_range(200, 300)
	rotation_degrees = r
	tween.interpolate_property($Sprite, "position", Vector2(0,0), Vector2(randomx, randomy), 1.5, Tween.TRANS_QUAD, Tween.EASE_OUT)

func _on_Area2D_area_entered(area):
	var p = get_global_mouse_position()
	var ob = orangebottom.instance()
	var ot = orangetop.instance()
	var splats = splat.instance()
	ob.global_position = p
	ot.global_position = p
	splats.global_position = p

Main world code:

extends Node2D

onready var orange = preload("res://orange.tscn")

#onready var fruits = [orange]
func _ready():

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if Input.is_action_just_pressed("click"):
	if Input.is_action_just_released("click"):

func _on_Timer_timeout():
	var fruit = orange.instance() #fruits[randi() % fruits.size()]
	fruit.global_position = $spawnpoint.global_position

I edited your post to fix the broken code you pasted. In future, hit the “code sample” button when pasting code and it will be formatted correctly.

kidscancode | 2021-05-09 06:36

There are three different places where you call interpolate_property(), but you didn’t indicate where the error occurred.

Either way, that error means that what you’re calling interpolate_property() on is null. So at least one of these is invalid:

onready var tween = $Tween
onready var splat = $splat
onready var fade = $fade

kidscancode | 2021-05-09 06:38