How does the Magnitude function not work properly?

hello! I have an issue with my script but I cannot seem to figure it out, I hope you can help!

the issue is that I have a magnitude function that when your humanoidRootPart is less than 15 studs away from the grass part it will tween to simulate wind.

but for some reason whenever you leave the radius and go back in the part won’t tween until you get super close to it(like almost touching the grass part)

here is the script I made let me know if you can figure out how to fix it

1 Like

I can give you two quick suggestions.

.1) Try printing the magnitude to see if there’s any issues with that.
.2) You can add math.abs() into your statement and do something like this:

 if math.abs((char2.HumanoidRootPart.Position - grass.Position).Magnitude) <= 15 then
--do stuff here.
end
1 Like

thanks, i will try this out rn and let you know how it works

I used the print feature but it says I’m in a radius right in front of the plant like it did before so there is something wrong with my script but i don’t what?

This does nothing. The magnitude of a vector should always be positive ( to understand why this is I recommend looking into the Pythagorean theorem )

As to the OP’s question, you might need to redfine char2 after the character dies. As of right now it seems like char2 will still hold a reference to the old character model even after the character has died.

1 Like

is it possible if you could show e how i could fix this