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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
D3LTA_Y 72
6 years ago
Edited 6 years ago

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!")
0
Hm it didn't work for some reason. What should I do? TheBeaver101 28 — 6y
0
What does output says? D3LTA_Y 72 — 6y
0
It says nothing... Hmm TheBeaver101 28 — 6y
0
Nevermind, just tweaked something. It works! Thank you so much! TheBeaver101 28 — 6y
Ad

Answer this question