I am trying to constantly print the Distance between the Torso and a Part in the workspace, I have literally tried every loop and cannot solve this. Any and all help is welcomed and appreciated, here is my code(script is in StarterCharacterScripts)
Torso = script.Parent.Torso magnitude = Torso.Position.Magnitude - workspace.One.Position.Magnitude Value = 0 while Value < 15 do Value = Value + 1 print(magnitude) wait(1) end
I always get the same distance between the two points and even if I move closer to the Part it never changes.
You have about two problems with your given script. First of all is how you're getting the magnitude, you should do it this way:
local Magnitude = (part.Position - Part.Position).magnitude
Even if the above code was used instead of your method of trying to get magnitude was implemented in your script, it still wouldn't work as you want. The Magnitude variable is already made as a value on line 2 while you never check again and again, causing this variable to consist of the same exact value. So to fix this, you can just do the bellow:
Torso = script.Parent.Torso magnitude = (Torso.Position - workspace.One.Position).magnitude Value = 0 while Value < 15 do Value = Value + 1 magnitude = (Torso.Position - workspace.One.Position).magnitude -- Now it's updated print(magnitude) wait(1) end