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

How to CanCollide = false at Taransparency = 1?

Brick = game.Workspace.Brick

function FallThrough()
if Brick.Transparency = 1 then
Brick.CanCollide = False

end

FallThrough()

Shouldn't this work?

1 comment

0

Make sure false is lowercase

3 answers

Calling the function only once will only make it run once. Using the Changed event will call the function every time any property of the brick changes.

local Brick = Game.Workspace.Brick

Brick.Changed:connect(function(prop)
	if prop == "Transparency" then
		if Brick.Transparency >= 1 then
			Brick.CanCollide = false
		else
			Brick.CanCollide = true
		end
	end
end)

1 comment

0

This is a smart use of the Changed event, though stating what was wrong before (syntax) and why you changed the form really should be in your answer

if Brick.Transparency = 1 then
Brick.CanCollide = False

You forgot something here, you need to and an end to the false statement, and make false lowercase.

if Brick.Transparency = 1 then
	Brick.CanCollide = false
end

Here's the full script:

Brick = game.Workspace.Brick

function FallThrough()
if Brick.Transparency = 1 then
	Brick.CanCollide = false
end

end

FallThrough()

1 comment

0

It didn't work. I put it in a separate script alongside another script to make transparency generally fade from 0-1 over the course of 1 second. Then the script waits 2 seconds and the brick reverts back to Transparency=0. For some reason once the block reaches transparency = 1, this script won't work

You Failed an if and then Statement

and Forgot to Add an End

Brick = game.Workspace.Brick

function FallThrough()
if Brick.Transparency == 1 then
Brick.CanCollide = False

end
end
FallThrough()

There you go.

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