Hi, i have a script that sould check for the Magnitude of 2 objects. The script gives an error.
if hit and (hit:IsA("Terrain") or hit.Name:lower() == "terrain") and HRP.Position - clientStructure.Position.Magnitude < maxPlacingDistance or HRP.Position - clientStructure.OpenPart.Position.Magnitude < maxPlacingDistancethen then
-- Error
Position is not a valid member of Model "Workspace.DimensionalChest"
The “DimensionalChest” (clientStructure) element is a Model, so i checked with a or for the PrimaryPart
Strangely enough, it seems to work on elements other than Terrain
local structurePart = clientStructure.PrimaryPart or clientStructure:FindFirstChild("OpenPart")
if (structurePart) then
local distanceFromStructure = (structurePart.Position - HRP.Position).Magnitude
if (hit:IsA("Terrain") and (distanceFromStructure <= maxPlacingDistance)) then
-- Do stuff here
end
end