Value Isn't Becoming Negative

I’m trying to turn the value of DodgeDirection negative when the AKey is true. The AKey 100% becomes true, it’s just that the value that it has never turns negative. I’ve tried multiplying it by -1, and many other ways and it just never turns into a negative version of itself.

Also is there a limit on how many parameters I can pass to a remotevent? It seems like the limit is 3.

1 Like

No, that looks right. Is anything else changing the variable?

I don’t think so? Here’s the rest:


The only thing could be multiplying it by dodge range, but that’s just 64.

I think it’s because the value is a Vector3, and not a number. With x = -x, it would work as an integer, but I’m not entirely sure if it can be done the same with Vector3s.

Maybe I’d get the LookVector, get the xyz values, separately turning them into negatives, then reconstructing it back into a Vector3?

Instead of checking for individual keys, you can use Humanoid.MoveDirection as a dodge direction, unless you need them only in 4 directions
For your solution, just multiply DodgeDirection by negative Vector3.one
image

Oh, I see now. You tried doing a Vector3.new(1,1,1) = -Vector3.new(1,1,1). Negative Vector3s don’t necessarily exist, as you need to change the values inside.

Both mine and @SolidTurret’s responses are correct. You can either separately make the values negative, to then reconstruct back into a Vector3, or multiply it by negative Vector3.One.

I changed it to this and yet it still doesn’t turn negative?


image

You got the format wrong. Instead of this:

DodgeDirection = Vector3.new(DodgeDirection*-Vector3.one)

Do this:

DodgeDirection *- Vector3.one

This simply gives me an error because it expects an equal sign somewhere.
So I tried:


Alongside DodgeDirection = DodgeDirection *- Vector3.one
They just never turn negative???

Well in the photo, he did variable = v3*-Vector3.one, which did work; so with the variable, wouldn’t it be this:

DodgeDirection = (DodgeDirection *- Vector3.one)

That still doesn’t work for some reason… Either way I’m going to just use movedirection since I should’ve thought of that before. If anyone ends up googling this sorry LOL

Perhaps you can multiply it by negative one (* -1) to get the negative?

How about we try the first solution I said?

We can try to turn the xyz values negative, to reconstruct back into a Vector3:

DodgeDirection = Vector3.new(DodgeDirection.X*-1,DodgeDirection.Y*-1,DodgeDirection.Z*-1)

Just use DodgeDirection = DodgeDirection * -1 you can multiply vectors with numbers.

She tried that. It strangely didnt work.

I’ve tried straight up setting the vector3 into a completely arbitrary number and it still is at (1, 0, 0) leading me to believe that something else is setting AKey to be (1, 0, 0). What that thing is, I have absolutely no idea.

If you set it to 0,0,0 and it’s still at 1,0,0 then something is definitely changing up the variable in some other if or function statements.

We can see if this is true by having that DodgeDirection being set, then a print right after, to see if it is doing it’s job, but the variable then later gets changed.

If that is the case, then go back to your original DodgeDirection = -DodgeDirection to see if that worked all along.

for some reason SKey is constantly set to true and that’s been messing everything up.


As a result, I can’t be asked fixing this already flawed method. I’ll just use movedirection.

Actually, you can use this method if you want to. If it works, just keep using it.

Nah, I was gonna eventually use it to do something that movedirection would have done way better. I have no idea how it didn’t come to my mind to use movedirection especially since I used it in one of my other functions.