Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Break is not a valid member of MeshPart?

Asked by 4 years ago

trying to make a part detect if whatever's touching it has a value called "Break" then it will run "test". any solutions?

script.Parent.Touched:Connect(function(hit)
    if hit.Break then
        print("test")
    end
end)
0
Is break in the characters body part, or just character? DarkDanny04 407 — 4y
0
in the torso, so in the bodypart 10x31x2019 -6 — 4y

1 answer

Log in to vote
0
Answered by
Alphexus 498 Moderation Voter
4 years ago
Edited 4 years ago

That errors because you aren’t checking for existence. Break doesn’t exist. If you want to check if it exists, use FindFirstChild. Try this script out:

script.Parent.Touched:Connect(function(hit)
      if hit:FindFirstChild("Break") then
            print("test")
      end
end)
Ad

Answer this question