Script not working

script.Parent.Touched:Connect(function(otherPart)
print(otherPart.Name)
–if otherPart.Locked == false then
otherPart.Anchored = false
local scri = script.Parent.Del:Clone()
scri.Parent = otherPart
scri.Enabled = true
local ex = Instance.new(“Explosion”)
ex.Visible = false
ex.Parent = otherPart
ex.Position = otherPart.Position
otherPart:BreakJoints()
–end
end)

Im making a tsunami and i want so whenever a part touches the tsunami it will get destroyed.
It doesnt work on parts but it works on a player character. The “touched” function doesnt work.

This a cleaned up version of the script, but from what I can see the script looks fine.
One of the main reason the Tsunami wouldn’t count other parts is because those parts are anchored and you most likely are moving the Tsunami via tween or cframe, etc.

.Touched only runs when game physics touches the part, for example, the moving of a character would allow the event to fire. Since you are changing the Tsunami’s movement via. Cframe, tween, or another method that is not a physics way the part won’t fire a .Touched event on other parts.

script.Parent.Touched:Connect(function(otherPart)
    print(otherPart.Name)
    if otherPart.Locked == false then
       otherPart.Anchored = false
       local scri = script.Parent.Del:Clone()
       scri.Parent = otherPart
       scri.Enabled = true
       local ex = Instance.new("Explosion")
       ex.Visible = false
       ex.Parent = otherPart
       ex.Position = otherPart.Position
       otherPart:BreakJoints()
    end
end)

Instead I’d look at region3 for this

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.