+1 vote

Invalid set index 'emitting' (on base: 'null instance') with value of type 'bool'.

I have no idea what the problem is, it worked perfectly a second ago:

extends KinematicBody

var direction = Vector3.FORWARD
var velocity = Vector3.ZERO

var vertical_velocity = 0
var gravity = 18

var movement_speed = 0
var walk_speed = 5
var run_speed = 12
var acceleration = 6
var angular_acceleration = 7

var jumps = 0
export var seeds = 0

var moving


func _physics_process(delta):
    #Moving
    if Input.is_action_pressed("ui_up") || Input.is_action_pressed("ui_down") || Input.is_action_pressed("ui_left") || Input.is_action_pressed("ui_right"):
        var h_rot = $Camroot/h.global_transform.basis.get_euler().y
        moving = true
        direction = Vector3(Input.get_action_strength("ui_left") - Input.get_action_strength("ui_right"),
                    0,
                    Input.get_action_strength("ui_up") - Input.get_action_strength("ui_down")).rotated(Vector3.UP,h_rot).normalized()
    else:
        movement_speed = 0
        moving = false

    velocity = lerp(velocity, direction * movement_speed, delta * acceleration)

    move_and_slide(velocity + Vector3.DOWN * vertical_velocity, Vector3.UP)




    # Jumping
    if is_on_floor():
        vertical_velocity = 0

        # Jumping
        if Input.is_action_pressed("jump"):
            $J_sound.play()
            $Jpart.emitting = true
            vertical_velocity = -10
            jumps = 1

        # Crouching
        elif Input.is_action_pressed("crouch"):
            if velocity.y > -20:
                velocity.y -= 1
        else:
            jumps = 0
        # Sprinting 
        if Input.is_action_pressed("sprint"):
            movement_speed = run_speed
            $Rpart.emitting = true

        else:
            movement_speed = walk_speed
            $Rpart.emitting = false

        # Basically if not_on_floor:
        $Camroot/h/v/Camera/Gui/TextureProgress.value -= 1
    else:
        vertical_velocity += gravity * delta

Where the problem occured:

$Rpart.emitting = false
$Jpart.emitting = false

        # Planning and crouching
        if Input.is_action_pressed("jump") && jumps == 1:
            if $Camroot/h/v/Camera/Gui/TextureProgress.value < 100:
                gravity = 10
                $Camroot/h/v/Camera/Gui/TextureProgress.value += 1.25
            else:
                gravity = 18
        elif Input.is_action_pressed("crouch"):
            gravity = 100
        else:
            gravity = 18
            movement_speed = 10
            $Camroot/h/v/Camera/Gui/TextureProgress.value -= .75
    # Making the player change direction
    $MeshInstance.rotation.y = lerp_angle($MeshInstance.rotation.y, atan2(direction.x, direction.z), delta * angular_acceleration)

    # Zooming
    if Input.is_action_just_released("zoom_in") && $Camroot/h/v/Camera.translation.z <=0:
        $Camroot/h/v/Camera.translation.z = $Camroot/h/v/Camera.translation.z + .5
    elif Input.is_action_just_released("zoom_out") && $Camroot/h/v/Camera.translation.z >=-5:
        $Camroot/h/v/Camera.translation.z = $Camroot/h/v/Camera.translation.z - .5


func _on_Area_body_entered(body):
    get_tree().reload_current_scene()

func _on_Jump_Pad_body_entered(body):
    vertical_velocity = -20

func _on_sunflower_seed_plus():
    seeds = seeds + 1
    $Camroot/h/v/Camera/Gui/Label.text = str(seeds)
    $Camroot/h/v/Camera/Gui/popup.play("New Anim")
Godot version 3.2.2
in Engine by (177 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.