Im trying to check and see if a humanoids root part is close to a vector3 position but I only want to check the x and z axis. I dont care were it is on the y axis.
this is what I got so far but it seems this does not work.
repeat
wait()
until
script.Parent.Parent.HumanoidRootPart.Position.X <= closestorb.Center.Position.X + 20 or
script.Parent.Parent.HumanoidRootPart.Position.X <= closestorb.Center.Position.X + -20 or
script.Parent.Parent.HumanoidRootPart.Position.Z <= closestorb.Center.Position.Z + 20 or
script.Parent.Parent.HumanoidRootPart.Position.Z <= closestorb.Center.Position.Z + -20
repeat
wait()
local newhumpos = (script.Parent.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(1,0,1)))
local neworbpos = (closestorb.Center.CFrame * CFrame.new(Vector3.new(1,0,1)))
local total = (newhumpos - neworbpos).Magnitude
until
but since Im waiting for the humanoid root part to be close to “closestorb”, what should I put below “until”?
wait()
local newhumpos = (script.Parent.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(1,0,1)))
local neworbpos = (closestorb.Center.CFrame * CFrame.new(Vector3.new(1,0,1)))
local total = (newhumpos - neworbpos).Magnitude
until total <= 20
there seems to have been an error with the value “total”
vector3 expected got cframe
lines used:
repeat
wait()
local newhumpos = (script.Parent.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(1,0,1)))
local neworbpos = (closestorb.Center.CFrame * CFrame.new(Vector3.new(1,0,1)))
local total = (newhumpos - neworbpos).Magnitude
until
total <= 20
repeat
wait()
local newhumpos = (script.Parent.Parent.HumanoidRootPart.CFrame * Vector3.new(1,0,1))
local neworbpos = (closestorb.Center.CFrame * Vector3.new(1,0,1))
local total = (newhumpos - neworbpos).Magnitude
until
total <= 20