GMS 2.3+ Having problems with bouncing effect


Hi, first time posting here. I have a problem I have been working on all day... and I can't figure out what's wrong.

Simple overview on how I want it to work: (TOP/DOWN Game)
I have an player object which is moved by a mouse click and release and sent in that direction where mouse released in a fixed velocity times length of the distance from player and mouse release point. All working well. Also collisions working well.
When player collides at "Wall" I want player to bounce back accordingly from which direction player was traveling at. This I have figured out, but problems starts to how exactly how make it work.

This is my "Wall" object, which should calculate what direction the player should travel in at a collision, controlled by a variable DIR_WAY.

var dir_new_leftright = 0;
var dir_new_updown = 0;
var dir_left_offset = 0;
var dir_buff = 180;

// When collided bounce off, check Collided Happened (fade out, die).
if (global.player_controll && player_ready){
    // DIR_WAY = 1 Calculate Left or Right Direction
    // DIR_WAY = 0 Calculate Up or Down Direction
    // DIR_WAY = -1 None
    if (DIR_WAY = 1) {
        // Direction LEFT / RIGHT
        dir_left_offset = direction - dir_buff;
        dir_new_leftright = 360 - dir_left_offset;
        direction = dir_new_leftright;
    if (DIR_WAY = 0){
        // Direction UP / DOWN
        dir_new_updown = 360 - direction;
        direction = dir_new_updown;   
    collided_happened = true;
And this code should then check if player is either near one X-axis of this "Wall" object or the Y-axis and set variable DIR_WAY accordingly to how it should calculate the direction bounce back.

if (DIR_WAY = -1){
    if (place_meeting(x - 5, y, o_wall_01) || place_meeting(x + 5, y, o_wall_01)) {
        DIR_WAY = 1;
    if (place_meeting(x, y - 5, o_wall_01) || place_meeting(x, y + 5, o_wall_01)) {
        DIR_WAY = 0;
} else {
    DIR_WAY = -1;
Problem with this code is that it can't set the calculation for the direction correctly. Works 1 out 5 times when it bounces from a wall at Y-axis then to a wall at X-axis or vice-versa.

I've been at this all day and can't figure out what to do to fix this... I created this post in hope if someone noticed what's wrong or maybe a solution to this.