I want to read the Density value of a Basepart and if it is under 1, it should do the things below it. For some reason, it gives this error when I try it;
attempt to index nil with 'Density'
Code;
local touching = script.Parent:GetTouchingParts()
for i,v in pairs(touching) do
if v:IsA("BasePart") then
if v.CustomPhysicalProperties.Density < 1 then
if not v:FindFirstChild("WaterVelocity") then
local velocity = script.Parent.WaterVelocity:Clone()
velocity.Parent = v
velocity.Position = Vector3.new(v.Position.X,(script.Parent.Size.Y/2)-1,v.Position.Z)
else
v.WaterVelocity.Position = Vector3.new(v.Position.X,(script.Parent.Size.Y/2)-1,v.Position.Z)
end
end
end
end