Edit: Found the problem, I was doing Vector3.new(target.Position) but position is already a vector so I was transforming a vector into a vector which was transforming it into 0,0,0
Alright so my title is probably a bit confusing so I'll try my best to explain my problem.
I want to see the distance between the character and a specific part that he clicks on. However, the two prints in my script are the same number and I can't seem to figure out why. I have 3 different parts that I click on and the number printed will be the same
For example, on part 1 I'll get the output as
24.933333
24.933333
then the second part
10.224434
10.224434
Then the third part is
50.400000
50.400000
I've been trying to figure out the problem but I'm new to using vectors so can someone please help.
I hope you can understand my problem? Here's the localscript in a tool
local UserInputService = game:GetService("UserInputService")
local Tool = script.Parent
local Player = game.Players.LocalPlayer
function onActivation()
local mouse = Player:GetMouse()
local Target = mouse.Target
local position2 = Target.Position --Probably here the mistake?
print(Player:DistanceFromCharacter(Vector3.new(position2))) -- Same as number below
print(Player:DistanceFromCharacter(Vector3.new(0,0,0))) -- Same as number above
end
Tool.Activated:Connect(onActivation)
