i have a question, i stole this wonderful raycast from online - but how do i make it damage entities the particles hit?
on right click:
if 1 of player's tool is stick:
if name of player's tool is "&4Apple Wand":
appleraycast(player, 20, 20, red)
function appleraycast(p: player, length: number, dmg: number, color: color):
set {_x} to 0
set {_l} to 0
loop {_length} times: #loops as many times as long as the length from the function input
add 1 to {_x}
add 0.25 to {_l}
set {_rg%{_x}%} to location {_l} meters infront of {_p}
set {_rg%{_x}%} to location 1.25 meters above {_rg%{_x}%} #aligns with where player is looking
set {_x} to 0
loop {_length}*10 times:
add 1 to {_x}
if {_color} is red:
show 4 red dust at {_rg%{_x}%} #change color or particle type
loop entities in radius 1.5 around {_rg%{_x}%}:
if loop-entity is not a player:
damage loop-entity by {_dmg}
stop #if you want your projectile to pierce entities, delete this line
loop blocks in radius 0.5 around {_rg%{_x}%}:
if loop-block is not air:
stop #projectile does not go through blocks, but passes through expected blocks