what is my mistake in this?

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

I have a problem in the code. I’m using GDScrip and I’m new to this. I am copying the code from a tutorial and I do not see the error.Is it possible that the tutorial is out of date?

extends KinematicBody2D

const moveSpeed = 25
const maxSpeed= 50

const jumpHeight = -300
const up = Vector2 (0,1)

const gravity = 15

onready var sprite = $Sprite
onready var animationPlayer = $AnimationPlayer

var motion = Vector2()

func _physics_process(delta):

motion.y += gravity

var friction = false

if Input.is_action_pressed ("ui_right"):
	  sprite.flip_h = true
	  motion.x = min(motion.x + moveSpeed, maxSpeed)

elif Input.is_action_pressed ("ui_left"):
	  sprite.flip_h = false
	  motion.x = max (motion.x - moveSpeed, maxSpeed)

	friction = true
if is_on_floor():
	if Input. is_action_pressed("ui_accept"):
		motion.y = jumpHeight
	if friction == true:
		motion.x = lerp (motion.x, 0, 0.5)
	if friction == true:
		motion.x = lerp (motion.x, 0, 0.01)

motion = move_and_slide(motion, up)

Can you describe the error?
Note that because of the messed up formatting I see more than 1 error but I am guessing that is just printing wrong.
The best way to post code in this format is to copy/paste from the editor into the text box then select all the code and press the {} on the toolbar above the text box.
Please edit your post to fix that.

LeslieS | 2022-12-30 05:00

:bust_in_silhouette: Reply From: Liam Steyn
    friction = true

In this line Play should be written with a lowercase p

    friction = true. 

I don’t know if that is your problem but it is something I spotted. I am also not an expert so there is a possibility that I missed something else.


 func physicsprocess(delta):

Should be written as

func _physics_process(delta):