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

What's wrong with my script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Everything was perfectly fine. Rotating it was awesome. Then I added a can-collide every time the block turn invisible then I get an error


local this = script.Parent while (true) do for i=0, 10 do this.Transparency = i/10 then CanCollide = true wait(0.1) end for i=10, 0, -1 do this.Transparency = i/10 wait(0.1) end end

1 answer

Log in to vote
1
Answered by 9 years ago

The reason is because you're not actually setting the CanCollide as a specific property of a part.

Additionally, although it isn't an error, rather than doing division when setting transparency, you can set the index increase value as a third reference.

To fix the original problem(s), you can add a reference as such:

local this = script.Parent

while (true) do
    for i=0, 10 do
        this.Transparency = i/10 then
        this.CanCollide = true
        wait(0.1)
    end
    for i=10, 0, -1 do
        this.Transparency = i/10
        wait(0.1)
    end
end

Also, if you'd like to not use division when doing this, you can do:

local this = script.Parent

while (true) do
    for i=0, 1,.1 do
        this.Transparency = i then
        this.CanCollide = true
        wait(0.1)
    end
    for i=1, 0, -.1 do
        this.Transparency = i
        wait(0.1)
    end
end
1
Omg thx I forgot to put "this.CanCollide" CjGamer1454 0 — 9y
Ad

Answer this question