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

How can I find out what block is touching what?

I want to be able to know what a block is touching for example: If block A touches block B it will change colour, but if the player touches block B it will not do anything. I cant seem to find out how to do this

1 answer

✓ Accepted answer

Check if the object that is touching the block is a part not a player or anything else.

local blocka = Workspace:FindFirstChild("block A") --Block A

blocka.Touched:connect(function(hit) --When block A is touched this event will fire.
	if hit.Name == ("block B") and hit:IsA("Part") then--If the object that touched block A is a part and it's name is 'block B'
		hit.BrickColor = BrickColor.new("Bright blue") --Block B will change color to 'Bright blue'
	end
end)

Visit http://wiki.roblox.com/index.php?title=Touched_(Event) to learn more about the Touched event.

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