If you have the ... position where your raycast hits a tile...
Just to add a quick comment on this: Unless something changed with the raycast extension, I don't recall that being a simple thing to calculate. You don't want to use the (x,y) location returned by the raycast, since that won't give you the position of the tile. It'll give you the position of the merged block of tiles.
Instead, you want to loop through the list of collided actors/terrain and find the one with the lowest "fraction" parameter. This will be the first object hit. To compute the (x,y) location of the hit, use
x = x1 + t * ( x2 - x1 ) y = y1 + t * ( y2 - y1 )
where t is the fraction, (x1,y1) is the location of the gun, and (x2,y2) is the other coordinate you pass to raycast. Once you have (x,y), then draw a line from (x1,y1) to (x,y)