Destroy(), Remove() and ClearAllChildren() isn’t not working for models,
and I don’t know what to do
please help me
local cash = script.Parent.Parent.Parent.Parent.Values.Cash
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("Price") then
cash.Value += hit:FindFirstChild("Price").Value
hit.Parent:Destroy()
end
end)
there aren’t any warns nor errors and I really want this done
:Remove is depracated, I recommend using :Destroy
and try adding print statements to see if it is being found
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("Price") then
print("Hello, world!")
cash.Value += hit:FindFirstChild("Price").Value
hit:Remove()
end
end)
And also try this
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Price") then
print("Hello, world!")
cash.Value += hit:FindFirstChild("Price").Value
hit:Remove()
end
end)
(Using hit parents checks the model not the children in it, you can’t touch a model only baseparts (Unions, Negative Parts, Intersections, etc.)
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Price”) then
print(“Hello, world!”)
cash.Value += hit:FindFirstChild(“Price”).Value
hit:Destroy()
end
end)
(Using hit parent checks the model not the children in it, you can’t touch a model only baseparts (Unions, Negative Parts, Intersections, etc.)
Never forget to add a “.Parent”
Like I used to do with kill parts when I first started.
Checking hit is a basepart
Checking hit parent is the parent (usually the characters model if you’re doing a kill part)