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

Need help with this script? [SOLVED]

Im trying to make the part vanish and have NoCollide and then reappear with CanCollide

function bananaz ()
    h = 0
    repeat 
    game.workspace.part.transparency = (h) + 0.2
    wait (1)
    until game.workspace.part.transparency == 1


    repeat
    game.workspace.part.transparency = (h) - 0.2
    wait (1)
    until game.workspace.part.transparency == 0
    game.workspace.part.cancollide = false

game.Workspace.Part.Touched:connect(bananaz)

Any help?

3 answers

✓ Accepted answer
local t = 1 -- How much time the transition takes
local intervals = 50 -- How smooth the transition is
local busy = false
script.Parent.Touched:connect(function()
	if not busy then
		busy = true
		for i  = 0, 1, 1/intervals do
			script.Parent.Transparency = i
			wait(t/intervals)
		end
		script.Parent.CanCollide = false
		for i  = 1, 0, -1/intervals do
			script.Parent.Transparency = i
			wait(t/intervals)
		end
		script.Parent.CanCollide = true	
		busy = false	
	end
end)

This works, tested it myself.

EDIT: Replaced "workspace.part" with "script.Parent". If you put the script in the brick it should work.

5 comments

0

Does this work for anchored bricks?

0

Also just a normal script or a LocalScript?

0

Works for anchored bricks and you should use this with a normal script

0

I just don't get it... when i touch the brick with the script in it, nothing happens it doesn't fade and it doesn't go NoCollide it just stays CanCollide :C

0

Updated answer.

function bananaz ()
    h = 0
    repeat
    game.workspace.part.transparency = (h) + 0.2
    wait (1)
    game.workspace.part.cancollide = false
    until game.workspace.part.transparency == 1

    repeat
    game.workspace.part.transparency = (h) - 0.2
    wait (1)
    until game.workspace.part.transparency == 0
    game.workspace.part.cancollide = true
 

game.Workspace.Part.Touched:connect(bananaz)

maybe this will work

1 comment

0

This one doesn't work :C

Im not sure if this is right but you could try and do

function bananaz()
game.workspace.part.Transparency = 0
for i = 1,50 do
game.workspace.part.Transparency = game.workspace.part.Transparency  + 0.2
game.workspace.part.CanCollide = false
wait(1)
end

for i = 1,50 do
game.workspace.part.Transparency = game.workspace.part.Transparency  - 0.2
game.workspace.part.CanCollide = true
end

game.Workspace.part.Touched:connect(bananaz)

I Think that should work :P

4 comments

0

I edited it try now

0

Still doesn't work. You could either send me a whole new script or just leave it. Your choice.

0

have you checked the output?

0

What's the "output"?

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