local val = script.Parent.Hit.Value
if val.Material == "Metal" --attempt to index nil with 'Material'
--stuff
end
the value is a object value, what causes this error?
local val = script.Parent.Hit.Value
if val.Material == "Metal" --attempt to index nil with 'Material'
--stuff
end
the value is a object value, what causes this error?
It’s saying the value of the ObjectValue is nil. Are you setting the value of the ObjectValue to a BasePart?
Yes, i checked, it does set it to a base part
local val = script.Parent.Hit.Value
print(typeof(val))
if val.Material == "Metal" --attempt to index nil with 'Material'
--stuff
end
Try adding a print statement to see what it says. If it prints “nil” then you’re not setting the value, or the value is being set after you’re checking the value.
Yep, nil. it runs before its set