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

sooooo i accidently made a lag script and i need to make a smooth transparency brick?

the title explains it all it times out the game, also dont test this it WILL crash yur computer

function touch()
	while true do
	for i = 1, 100 do
	if script.Parent.Transparency + 0.1 then
		script.Parent.CanCollide = false
		if script.Parent.Transparency == 0 then
			for i = 1, 100 do
				if script.Parent.Transparency - 0.1 then
					script.Parent.CanCollide = true
					if script.Parent.Transparency == 1 then
						wait(1)
					end
				end
			end
		end
		
	
end
end
end
end 
script.Parent.Touched:Connect(touch)

1 comment

0

._. Man, I don't even wanna ask about this mess.

2 answers

I'm assuming that you need a brick that changes its transparency from 0 to 1. (I am not too sure what is the value for opaque and transparent.)

Also, I assume that there is no wait in the for i and while true do loop.

So here is the script, I assume.

function touch()

for i = 1,100 do
	script.Parent.Transparency = script.Parent.Transparency - 0.01
	wait(0.05)
end

If you want CanCollide to be turned off, you can add it before the loop. :>

3 comments

0

omg i am very new to FOr Loops and stuff so i just tried to make iit lol

0

I mean experimenting is the best way to learn and memorise for me.

0

Also, accept my answer?

The loop seem not good at all, you should add wait(5) to anti-lag.

function touch()
    while true do
    for i = 1, 100 do
    if script.Parent.Transparency + 0.1 then
        script.Parent.CanCollide = false
        if script.Parent.Transparency == 0 then
            for i = 1, 100 do
                if script.Parent.Transparency - 0.1 then
                    script.Parent.CanCollide = true
                    if script.Parent.Transparency == 1 then
                        wait(1)
                    end
                end
            end
        end


end
end
wait(5)
end
end 
script.Parent.Touched:Connect(touch)

That's all.

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