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

How to do an If brick is touching or player or another brick?

I want to make a robot that can detect their surroundings. http://prntscr.com/pbypos Here is what I want:

while true do wait()
	if brick is touching player or another brick then
 		run my touching code
	else
		run my not touching code
	end
end

Please help!?

1 comment

0

GetTouchingParts() returns all parts being touched in a function, .Touched returns parts being touched in an event..

1 answer

try this use :GetTouchingParts()

local touch = script.Parent
script.Parent.Touched:Connect(function(hit)
	while true do wait(0.1)
		touch:GetTouchingParts(print("Touched")) -- i just found it easier to print
else
	-- put what you want here
	end
end)

1 comment

0

not working

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