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

how do you change the colour of a block when another block is touched?

hi, the last thing blocking me from finishing my game is that i don't know how to have 1 block change colour when a different block is touched. for example if i have block A and block B, i want block B to change red when i touch block A. i hope someone knows how to do this. i tried doing it on my own, here is my code:

function onTouched(hit) if hit.Name=="check1" then script.Parent.BrickColor = BrickColor.new("Really Red") end end script.Parent.Touched:connect(onTouched)

i hope this was understandable, thanks from poopypigeon245.

1 comment

0

check1 was the name of the block i tried to turn red

1 answer

✓ Accepted answer
local parta = game.Workspace.PartA;
local partb = game.Workspace.PartB;

parta.Touched:connect(function()
	partb.BrickColor = BrickColor.Red();
end)

2 comments

0

what parts of that do i need to swap? it wasn't working when i replaced PartA and PartB with the names of the models, please could you tell me what i might be doing wrong? thanks for the help from poopypigeon245

0

oh sorry i forgot to change one of the parts. thank you so much for the help!

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