Okay so I am working on a detection function for my game. It is detecting if the player is within a certain distance of the plane so I can then play engine sounds.
local plane = workspace.PropellerPlane
local primaryPart = workspace.PropellerPlane:GetPrimaryPartCFrame()
local primaryPartVector3 = Vector3.new(primaryPart.p)
local playerCFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
local playerVector3 = Vector3.new(playerCFrame.p)
local magnitudePrint = (primaryPartVector3 - playerVector3).Magnitude
while true do
print (primaryPart.p)
print(magnitudePrint)
wait(.1)
end
I know this code is extremely messy but I am just trying to debug why it won't work.
When I have it print to the console the magnitudePrint returns 0 no matter what I do in game.

7 comments
Hmm.. this should work. You could try defining the Vector3 variables without using the Vector3.new functions, since '.p' returns a vector of the given CFrame anyways.
Does workspace.PropellerPlane have a PrimaryPart set?
No luck. Now it prints 2255.9067382812
The primary part is set in the following order- workspace/PropellerPlane(the model)/Fuselage/primaryPart
well uh is that ur distance from the propellers cx
No, the propellers are in a separate directory
I think I know what's happening. Send a message to the #scripting-questions channel in discord and I'll explain.