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

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

Asked by 6 years ago

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.

0
check1 was the name of the block i tried to turn red poopypigeon245 22 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
local parta = game.Workspace.PartA;
local partb = game.Workspace.PartB;

parta.Touched:connect(function()
    partb.BrickColor = BrickColor.Red();
end)
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 poopypigeon245 22 — 6y
0
oh sorry i forgot to change one of the parts. thank you so much for the help! poopypigeon245 22 — 6y
Ad

Answer this question