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

How do i make A brick change transparency when A brick touches it?

So i have a tool to throw a ball and i have a brick. Now i want the brick to be transparent when the ball touches it. I'm not a very good scripter but i know that it has something to do with the TouchedEvent. I would appreciate any help. Thanks...

1 answer

✓ Accepted answer
function whenTouched(part)
	if part.Name = "Name of the Ball" then
		local x = script.Parent
		x.Transparency = 1

	end
end

script.Parent.Touched:connect(whenTouched)

This script will allow the brick to change transparency when the ball (any other brick will not work) touches the surface of the brick. On the if part.Name = "Name of the Ball" line of code, change the text inside the speech marks to the name of the ball on the workspace or where ever it is located, if it is Ball then your code would be

function whenTouched(part)
	if part.Name = "Ball" then
		local x = script.Parent
		x.Transparency = 1

	end
end

script.Parent.Touched:connect(whenTouched)

Hope this works. Remember to insert this code in to a normal script, which should be inside the brick that you want to become transparent.

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