Can someone help me, my code shows this error when I hover over something that is not a model (like the Baseplate)
function deleteselect()
if dl == true then
local sl = game.Players.LocalPlayer:GetMouse().Target
--get the model
--print(sl)
if sl then
model = sl
--continue for find a folder
if model.Parent then
while model.Parent ~= game.Workspace.Builded do
model = model:FindFirstAncestorOfClass("Model")
if model then
if model.Parent.Name == "Builded" then
break
end
end
end
end
Since you redefine the model variable to Instance:FindFirstAncestorOfClass("Model"), this method will return nil for any Instance that doesn’t a Model as an ancestor, and thus, the model variable will also become nil.