# Question about Unit 6 Lesson 6

in lesson 6 puzzle 15 I have to admit that I am stumped. I have tried multiple methods but keep getting stuck trying to enter a variable in as an id. What solutions have others come up with. Could we get some hints for this puzzle going forward?

Iâ€™m not sure I understand the question - when you say â€śenter a variable in as an idâ€ť do you mean using a variable in place of an element ID in a block like setText? If so, what kind of behavior are you seeing when you try to do it? FWIW, this puzzle has been removed from the next version of the Unit 6, expected to be released by the end of the month.

Does anybody have any sample solutions to the final motorcycle puzzle? I am a see when it comes to CS and I am piloting this for my school. We(Students and myself) are stumped on this one.

Is this the correct code for Lesson 6 Puzzle 16 (motorcycle with slider):

// Set the speed of the motorcycle
var speed = 10;

// Move the motorcycle up when the left button is clicked
onBoardEvent( buttonL, â€śpressâ€ť, function(event) {
var y = getProperty(â€śmotorcycleâ€ť, â€śyâ€ť);
setProperty(â€śmotorcycleâ€ť, â€śyâ€ť, y - speed);
});

// Move the motorcycle down when right button is clicked
onBoardEvent( buttonR, â€śpressâ€ť, function(event) {
var y = getProperty(â€śmotorcycleâ€ť, â€śyâ€ť);
setProperty(â€śmotorcycleâ€ť, â€śyâ€ť, y + speed);
});
onEvent(â€śsliderâ€ť, â€śchangeâ€ť, function(event) {
speed = getProperty(â€śsliderâ€ť, â€śvalueâ€ť);
});

1 Like

You need to create an event that sets the speed variable to the slider value when the slider is changed. See below:

// Set the speed of the motorcycle
onEvent(â€śsetSpeedâ€ť, â€śchangeâ€ť, function(event) {
var speed = getProperty(â€śsetSpeedâ€ť, â€śvalueâ€ť);

// Move the motorcycle up when the left button is clicked
onBoardEvent( buttonL, â€śpressâ€ť, function(event) {
var y = getProperty(â€śmotorcycleâ€ť, â€śyâ€ť);
setProperty(â€śmotorcycleâ€ť, â€śyâ€ť, y - speed);
});

// Move the motorcycle down when right button is clicked
onBoardEvent(buttonR, â€śpressâ€ť, function(event) {
var y = getProperty(â€śmotorcycleâ€ť, â€śyâ€ť);
setProperty(â€śmotorcycleâ€ť, â€śyâ€ť, y + speed);
});
});