Discuss Scratch

AishaCoding
Scratcher
6 posts

How do I fix my death scripts this time.

Last time,all my scripts weren't working,but,this time my slime never dies and the scripts don't stop even when the health is under 1…

when green flag clicked
set (lives) to [5]


when green flag clicked
forever
if <touching [spike] ?> then
change (lives) by (-1)
broadcast [death]
go to x: (-218) y: (-3)
end
end


when green flag clicked
if <(lives) < [1]> then
change [ghost] effect by (100)
stop [other scripts in sprite]
stop [this script]
end

Last edited by AishaCoding (Oct. 9, 2024 14:25:24)

Gladius247
Scratcher
68 posts

How do I fix my death scripts this time.

Could you post the project? I could test why it doesn't work

Antartica is so cool!
MineTurte
Scratcher
500+ posts

How do I fix my death scripts this time.

AishaCoding wrote:

Last time,all my scripts weren't working,but,this time my slime never dies and the scripts don't stop even when the health is under 1…

when green flag clicked
set (lives) to [5]


when green flag clicked
forever
if <touching [spike] ?> then
change (lives) by (-1)
broadcast [death]
go to x: (-218) y: (-3)
end
end


when green flag clicked
if <(lives) < [1]> then
change [ghost] effect by (100)
stop [other scripts in sprite]
stop [this script]
end

This is caused because you put stop this script under stop other scripts in sprite. Basically the stop this script stops the script stoping other scripts in sprite if you know what I mean.


if I helped you out Consider giving me a blockbit donation!
Jupyter Notebook is literally the best programming interface prove me wrong I dare you

█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█❖█



Signature color gradients here
mariocraft987
Scratcher
100+ posts

How do I fix my death scripts this time.

put all of this data into one script
when green flag clicked
set [lives v] to [5]
repeat until <(lives) < [1]> // checks if lives is 0 or less
if <touching [spike v] ?> then
change [lives v] by [-1] // what ever you want to do
broadcast [death v]
go to x: [-218] y: [-3]
...
end
end
stop [other scripts in sprite v]
// dont use "stop this script", the script already ends

Last edited by mariocraft987 (Oct. 9, 2024 17:25:02)


START OF MY SIGNATUREEE

Heyy! I am the founder of Bark Coding
I know HTML, Javascript, Python, I'm currently learning C++ and Java.

(PI :: #ffd86b) // Returns 3.1415926...
Alert [Hello, World!] :: #07f290 // Alerts "Hello, World!"
- AtomicBolts
AishaCoding
Scratcher
6 posts

How do I fix my death scripts this time.

OMG THANK YOU !!
RadiusGames46
Scratcher
100+ posts

How do I fix my death scripts this time.

your original code did not work for a very obvious reason

AishaCoding wrote:

when green flag clicked
if <(lives) < [1]> then
change [ghost] effect by (100)
stop [other scripts in sprite v]
stop [this script v]
end
you are only checking if the slime has run out of lives once at the beginning of the game; where the slime's health has already been set to 5
this needs to be in a forever loop

when this sprite mrffrmffmr::hat events
AishaCoding
Scratcher
6 posts

How do I fix my death scripts this time.

omg speaking of that I have scripts for my key


when I receive
if <<(Scene) = [9]> or <(Scene) = [16]>> then 
show


else
hide
wait until <<(Scene) = [9]> or <(Scene) = [9]>>
end

Powered by DjangoBB