If I try to add multiple names to “collect” the mesh for money, the entire script does not work. “Visor2007” is the one that functions.
local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue
script.Parent.Touched:Connect(function(Hit)
if Hit.Name == "Visor2007" and Hit:FindFirstChild("CashValue") then
CashValue.Value += Hit:FindFirstChild("CashValue").Value
Hit:Destroy()
end
end)
local Names = {"Visor2007"}
local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue
script.Parent.Touched:Connect(function(Hit)
if table.find(Names, Hit.Name) and Hit:FindFirstChild("CashValue") then
CashValue.Value += Hit:FindFirstChild("CashValue").Value
Hit:Destroy()
end
end)
If all your meshes had the child “CashValue”, you could just get rid of the first part of the IF statement and just do if Hit:FindFirstChild("CashValue") then because it’s highly unlikely a mesh that is not supposed to give money would have that child.
This would save you from having to add hundreds of names, like you said you would need to do.