Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to detect what part is hitting another part?

Is it possible to detect what part is hitting another part?

I wish to make it so that if a part named "One" hits a part named "Back" then it will make "Back"'s transparency equal to 1.

1 answer

✓ Accepted answer

You will need to use a Touched event, passing the part called "Back" as the target of the function parameter, using an "if" condition, like this:

local one = workspace:WaitForChild("One") -- Your "One" part.
local Back = workspace:WaitForChild("Back") -- Your "Back" part.


Back.Touched:Connect(function(Part) -- "Part" is the parameter what we want to be "One".
   if Part.Name == "One" then -- if "One" hits "Back" then:
         print("It is One!")
         Back.Transparency = 1
   else
      print("It isn't One, it is".. Part.Name.."!")
      end
end)

print("ola mundo da lua!")

4 comments

0

Hm it didn't work for some reason. What should I do?

0

What does output says?

0

It says nothing... Hmm

0

Nevermind, just tweaked something. It works! Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.