So i want to know how could i destroy a part once it touches another part with a keyword in it
this is my current script:
script.Parent.Touched:Connect(function(touched)
if string.find(touched.Name, "d_", 2) then --cant figure out how would the script detect a keyword in a string
touched:Destroy()
print("destructed")
else
print("not destructable")
end
end)
At first to make it work you don’t need that third argument so it would be string.find(touched.Name, "d_") also if you use touch event only in destructible parts you can disable “Can touch” property for non destructible parts and then your code will be:
if string.sub(touched.Name, 1, 2) == "d_" then
--Do code.
end
if string.find(touched.Name, "^d_") then
--Do code.
end
if string.match(touched.Name, "^d_") then
--Do code.
end