Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
- SamuraiNinjaBento
-
Scratcher
82 posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
https://scratch.mit.edu/projects/256921833/
How can I make the coin teleport to a random location within the borders of the play area when the player touches the coin?
How can I make the coin teleport to a random location within the borders of the play area when the player touches the coin?
- Rickyickerson
-
Scratcher
80 posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
if touching (coin) then
go to pick random x (180) to (-180) y (180) to (-180
Should work.
go to pick random x (180) to (-180) y (180) to (-180
Should work.
Last edited by Rickyickerson (Oct. 26, 2018 17:47:33)
- kieranblackley
-
Scratcher
500+ posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
It is quit simple. In the Coin sprite add this line of code into the if statement:
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley
go to x: (pick random (-89) to (227)) y: (pick random (-167) to (167))I hope that sorted your problem!
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley
Last edited by kieranblackley (Oct. 26, 2018 17:49:32)
- SamuraiNinjaBento
-
Scratcher
82 posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
It is quit simple. In the Coin sprite add this line of code into the if statement:go to x: (pick random (-89) to (227)) y: (pick random (-167) to (167))I hope that sorted your problem!
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley
Thank you for that! It works like I imagined now. Do you by chance know how to solve the lag problem when too many enemies spawn?
- kieranblackley
-
Scratcher
500+ posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.It is quit simple. In the Coin sprite add this line of code into the if statement:go to x: (pick random (-89) to (227)) y: (pick random (-167) to (167))I hope that sorted your problem!
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley
Thank you for that! It works like I imagined now. Do you by chance know how to solve the lag problem when too many enemies spawn?

- SamuraiNinjaBento
-
Scratcher
82 posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.
Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
- kieranblackley
-
Scratcher
500+ posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
Now that I have had a little think about, here is a solution to the lag problem. If it does not fix anything, I am sorry. It might be your computer causing the problem:I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.
Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!

- SamuraiNinjaBento
-
Scratcher
82 posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
Now that I have had a little think about, here is a solution to the lag problem. If it does not fix anything, I am sorry. It might be your computer causing the problemI am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.
Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
Here is my computer I am on right now, my computer at my house is much better though. This is my school computer: My browser / operating system: ChromeOS 10895.78.0, Chrome 69.0.3497.120, Flash 31.0 (release 0)
- kieranblackley
-
Scratcher
500+ posts
How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?
When you get home view the project and it should be better.Now that I have had a little think about, here is a solution to the lag problem. If it does not fix anything, I am sorry. It might be your computer causing the problemI am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.
Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
Here is my computer I am on right now, my computer at my house is much better though. This is my school computer: My browser / operating system: ChromeOS 10895.78.0, Chrome 69.0.3497.120, Flash 31.0 (release 0)

- Discussion Forums
- » Help with Scripts
-
» How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?