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

How can I find out what block is touching what?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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.

Ad

Answer this question