Im trying to make something judging by the distance of the parts, here is what I have so far,
local lastdist, lastv, closestdist
group = script.Parent
for i,v in pairs(group:GetChildren()) do
lastdist = distance
distance = (game.Players.LocalPlayer.Character.Torso.Position - v.Position).magnitude
if lastv ~= nil then
lastdist = (game.Players.LocalPlayer.Character.Torso.Position - lastv.Position).magnitude
end
if lastdist ~= nil and distance < lastdist then
closestdist = distance
end
lastv = v
end
print(closestdist)
There is no error but it isnt printing it. Please help!
PS: it's in a local script

1 comment
thanks!