i tried onTouch but it also does it for the player also.
✓ ANSWER ACCEPTED
How do i make when a certain block touches another block it activates something?
2 answers
✓ Accepted answer
local function PartTouched(TouchedPart)
print(TouchedPart.Name .. " has touched " .. Part.Name)
end
Part.Touched:connect(PartTouched)
This is probably what you have so far, if you want to check the the part touching is not a player, then you must add conditions to it.
local function PartTouched(TouchedPart)
local Player = Game.Players:GetPlayerFromCharacter(TouchedPart.Parent)
if Player == nil then
print(TouchedPart.Name .. " has touched " .. Part.Name)
end
end
Part.Touched:connect(PartTouched)
As you see here we're checking if the touched part is a character or not by using :GetPlayerFromCharacter() which will return the Player or Nil (Allowing us to check that it is indeed a character or not)
1 comment
0
thanks
Use this. It will check if the name is equal to the part that it needs to activate;
script.Parent.Touched:connect(function(hit) --assuming the script is inside the part that will get hit. (change it to where ever the part is)
if hit.Name=="PartThatItNeedsToActivate" then
--code
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Add an if to your onTouch that checks the part name