Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Cloud (time of completion) high score not working
- skedex
- Scratcher
3 posts
Cloud (time of completion) high score not working
i need help with my script. i am trying to make a timed race game with multypl levels. on the final level, when they cross the finish line the code is suppose to: set the current time on the timer as the players score, if it is higher than the high score it is set as the new high score. but it is not working! can some one help ?? this is the code:
when green flag clicked(sorry can't get rid of the red part )
if <touching [car v] ?> then
set [score v] to (timer)
end
if << <[score] = (☁ highscore)>> or <[score] < [☁ highscore]>> then
set [☁highscore v] to [score]
set [playerv] to (username)
end
Last edited by skedex (June 12, 2017 16:23:11)
- DanloVorje
- Scratcher
100+ posts
Cloud (time of completion) high score not working
Make sure there's a forever loop around those two “if” blocks so the script continues to check if its touching the car after the green flag is clicked. Also, if the score is the time it took for the player to finish the race, wouldn't a lower score be better, in which case you'd want to set “highscore” to “score” if score < highscore?
Hope this helps!
–Danlo
Hope this helps!
–Danlo
What I'm working on right now: Isle of Dolor
- dual_creator43
- Scratcher
1000+ posts
Cloud (time of completion) high score not working
First of all, this is how it should be: i need help with my script. i am trying to make a timed race game with multypl levels. on the final level, when they cross the finish line the code is suppose to: set the current time on the timer as the players score, if it is higher than the high score it is set as the new high score. but it is not working! can some one help ?? this is the code:when green flag clicked
if <touching [car v] ?> then
set [score v] to (timer)
end
if < <[score] = (☁ highscore)>> or <[score] > [☁ highscore]>> then
set [☁highscore v] to [score]
set [playerv] to (username)
end
when green flag clickedSecond of all, letters are not allowed in cloud variables. If you want to add letters, you need to encode them into numbers, then decode them back into letters. Also, I don't know what the variable “playerv” is for because since it's not a cloud variable, the username will not be stored for everyone to see.
reset timer
repeat (3) // if you have 3 laps, and if you start behind the finish line
wait until <touching [car v] ?>
wait until <not <touching [car v] ?>>
end
if <touching [car v] ?> then
set [score v] to (timer)
wait until <not <touching [car v] ?>> // just to be safe
end
if <(score) < (☁ highscore)> then
set [☁ highscore v] to (score) // notice how I didn't add the username
end
I'm dual_creator43, and I hope I've done well with anything. (Projects, forum replies, etc.) My Scratch habits include:
- checking my inbox
- being active in the forums
- working on my projects (sometimes)
My most famous quote: “Nothing good ever comes from posting near the end of a page.”
This is probably the best post anyone has ever made for me.
Don't you hate it when your signature isn't big enough to show everything you put in it?
But I guess it doesn't matter since you're (probably) using Shift+↓.
- stickfiregames
- Scratcher
1000+ posts
Cloud (time of completion) high score not working
Using the timer for things like that is a bad idea anyway, because it means the score is dependent on how fast the player's computer is. It's better to count how many times it runs through the loop that controls the car, and use that as the score.
- Discussion Forums
- » Help with Scripts
- » Cloud (time of completion) high score not working