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

What's wrong with my script?

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

✓ Accepted answer

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 comment

1

Omg thx I forgot to put "this.CanCollide"

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