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

How to CanCollide = false at Taransparency = 1?

Asked by
Scerzy 85
10 years ago
Brick = game.Workspace.Brick

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

end

FallThrough()

Shouldn't this work?

0
Make sure false is lowercase Link43758 175 — 10y

3 answers

Log in to vote
1
Answered by
Ekkoh 635 Moderation Voter
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

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)
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 BlueTaslem 18071 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
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()

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 Scerzy 85 — 10y
Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
10 years ago

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.

Answer this question