I am making a damage script for a tornado game, theres a value in every part that has the windspeed need to get picked up, however my damage script does not want to work properly, it checks if the tornado has a greater mph than the windspeed thats needed for the part to be picked up, then it picks it up. but the thing is its not working here, my script checks every part. so if it comes across a part without a value. it breaks. how could i fix this?
while wait(0) do
local RunService = game:GetService("RunService")
for i,hit in pairs(game.Workspace:GetDescendants()) do
if hit:IsA("BasePart") or hit:IsA("WedgePart") then
if (Vector3.new(script.Parent.Position.X, 0, script.Parent.Position.Z) - Vector3.new(hit.Position.X, 0, hit.Position.Z)).Magnitude <= 271 then
if hit:WaitForChild("windspeedneeded").Value <= script.Parent.windspeed.Value then
end
end
end
end
end