I have a block that I need to be destroyed on hit with another block. here is the script I have
local partToHit = game.workspace.DeletePoints.DeleteBlock1
script.Parent.Touched:Connect(function(hit)
if hit == partToHit then
print("Hit!")
script.Parent:Destroy()
end
end)
so it is never getting to the ‘print (“Hit!”)’ part?
Maybe have a print to see what is in ‘hit’
local partToHit = game.workspace.DeletePoints.DeleteBlock1
print("partToHit is ",partToHit)
script.Parent.Touched:Connect(function(hit)
print("partToHit is ",partToHit)
print("hit is ",hit)
if hit == partToHit then
print("Hit!")
script.Parent:Destroy()
end
end)
Do you have more than one item called DeleteBlock1 as a child of DeletePoints? If so you should change the if to check name and parent not the specific part.
local partToHit = game.workspace.DeletePoints.DeleteBlock1
script.Parent.Touched:Connect(function(hit)
if hit.Name == “DeleteBlock1” and hit.Parent == game.Workspace.DeletePoints then
print("Hit!")
script.Parent:Destroy()
end
end)