# 21.20 CSD--ERROR: Line: 104: Error: Error: overlap can only be checked between sprites or groups

**URL:** <https://forum.code.org/t/21-20-csd-error-line-104-error-error-overlap-can-only-be-checked-between-sprites-or-groups/22747>\
**Category:** CS Discoveries\
**Tags:** csd-unit-3\
**Created:** [November 29, 2018, 9:11pm UTC](https://forum.code.org/t/21-20-csd-error-line-104-error-error-overlap-can-only-be-checked-between-sprites-or-groups/22747 "2018-11-29T21:11:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfeld](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/lfeld/32/3504_2.png) [@lfeld](https://forum.code.org/u/lfeld)\
**Post date:** [November 29, 2018, 9:11pm UTC](https://forum.code.org/t/21-20-csd-error-line-104-error-error-overlap-can-only-be-checked-between-sprites-or-groups/22747/1 "2018-11-29T21:11:14Z")

</div>

Any help you can give would be great!

// Variables  
var score = 0;  
// Create Sprites  
var platform = createSprite(90,-10);  
platform.setAnimation(“platform”);  
platform.velocityY = 1;  
platform.setCollider(“rectangle”);

var platform2 = createSprite(280,200);  
platform2.setAnimation(“platform”);  
platform2.velocityY = 1;  
platform2.setCollider(“rectangle”);

var star = createSprite(randomNumber(50,350),randomNumber(-30,-60));  
star.setAnimation(“star”);  
star.velocityY = 2;

var star2 = createSprite(randomNumber(50,350),randomNumber(-30,-60));  
star2.setAnimation(“star”);  
star2.velocityY = 2;

var player = createSprite(200,350);  
player.setAnimation(“alien”);  
player.setCollider(“rectangle”);

function draw() {  
// draw the background  
background1();  
if (score \>= 100) {  
background2();  
}  
showScore();  
// update the sprites  
loopPlatforms();  
loopPlatforms2();  
loopStars();  
playerFall();  
controlPlayer();  
playerLands();  
collectItems();  
drawSprites();  
}

// Functions  
function background1() {  
background(“darkBlue”);  
noStroke();  
fill(“yellow”);  
ellipse(randomNumber(0, 400), randomNumber(0, 400), 3, 3);  
ellipse(randomNumber(0, 400), randomNumber(0, 400), 3, 3);  
ellipse(340, 50, 60, 60);  
fill(“darkBlue”);  
ellipse(320, 30, 60, 60);  
}  
function background2() {  
background(“lightblue”);  
noStroke();  
fill(“yellow”);  
ellipse(randomNumber(0, 400), randomNumber(0, 400), 3, 3);  
ellipse(randomNumber(0, 400), randomNumber(0, 400), 3, 3);  
ellipse(340, 50, 60, 60);  
}  
function showScore() {  
fill(“white”);  
textSize(20);  
text("Score: ",10, 10, 80, 20);  
text(score,75, 27);  
}  
function loopPlatforms() {  
if (platform.y === 400) {  
platform.y = -10;  
}}  
function loopPlatforms2() {  
if (platform2.y === 400) {  
platform2.y = -10;  
}}  
function loopStars() {  
if (star.y \> 410) {  
star.x = randomNumber(50,350);  
star.y = randomNumber(-10,-50);  
}  
}  
function playerFall() {  
player.velocityY = 2;  
}  
function controlPlayer() {  
if (keyDown(“up”)) {  
player.y = player.y - 5;  
}  
if (keyDown(“right”)) {  
player.x = player.x + 5;  
}  
if (keyDown(“left”)) {  
player.x = player.x - 5;  
}  
}  
function playerLands() {  
player.collide(platform);  
}

function collectItems() {  
if (player.isTouching(“star”)) {  
score = score + 1;  
star.x = randomNumber(50,350);  
star.y = -10;  
}  
if (player.isTouching(“star2”)){  
score = score + 1;  
star2.x = randomNumber(50,350);  
star2.y = -10;  
}  
}

---

<div class="post-metadata">

**Author:** ![elizabeth\_admin](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@elizabeth\_admin](https://forum.code.org/u/elizabeth_admin)\
**Post date:** [November 30, 2018, 3:34am UTC](https://forum.code.org/t/21-20-csd-error-line-104-error-error-overlap-can-only-be-checked-between-sprites-or-groups/22747/2 "2018-11-30T03:34:27Z")

</div>

Hi, in your `collectItems` function, you are using the string (quote) `"star"` rather than the sprite variable (no quote) `star` when you called the `isTouching` method. `isTouching` can only be used with sprites, not with strings.

(The `overlap` method checks whether two sprites overlap with each other and is used with `isTouching`, `collide`, `displace`, `bounce`, and `bounceOff`, so when there is a problem with overlap, those methods are usually where the problem is triggered.)

Elizabeth
