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

OnTouch vanish brick NoCollide? [SOLVED]

The player touches a brick (OnTouch) and the brick slowly vanishes within 5 seconds. When the brick is completely gone it goes into NoCollide.

After another 5 seconds the brick reappears and goes back into CanCollide.

Can i have the script for this please?

Thank you.

2 answers

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)

There probably is a better way of doing this but this is the only way I know how to do it so hope this helps :D

1 comment

0

This doesn't work ghostbeater12.

Just to begin with, I'd just like to say that this is my first actual answer that involves proper scripting, so please bear with me if I screw up a little. I'm also not the best scripter in town, and if anyone wants to edit what I've made or let me know of anything I can change, please let me know. :) Also, it's a slightly long post. I went a bit overboard when typing it when I started.

Ok, so having played around with Ghostbeater12's script, I have rewritten it a bit, added comments on every line that I could explain for, and tested it. It should work.

Db = false --Sets the variable Db(Short for Debounce) to false.

function vanish() --Run the Vanish function
    if not Db then --If Db == false then do all of the below.
	Db = true --Set Db to true so the function doesn't run more than once at a time
	script.Parent.Transparency = 0 --I(Jackd44, :P) added this as some crazy stuff was happening during testing, don't worry.
    repeat --Repeat this block of code
	wait(1) --Waits for a second
    script.Parent.Transparency = script.Parent.Transparency + 0.2 --Make the brick 0.2 more Transparent
    until script.Parent.Transparency == 1 --Stop this block of code when Transparency == 1, so when it's invisible.
    script.Parent.CanCollide = false --Now you can walk through the brick!
    wait(3) --Stays vanished for 3 seconds
    script.Parent.CanCollide = true --Now you can't walk through the brick!

    repeat --Repeats the block of code below
	wait(1) --Waits a second
    script.Parent.Transparency = script.Parent.Transparency - 0.2 --Makes it 0.2 more visible.(Pardon the grammar here. :) )
    until script.Parent.Transparency <= 0 --When it's fully visible or at negitive transparency(was getting odd stuff during testing, better to be safe than sorry), stop!

    Db = false --Db is false again, so the vanishing process can occur again!
end
end --Tying up some loose ENDS, haha, get it... No? Okay. Good thing I didn't make any other jokes.

script.Parent.Touched:connect(vanish) --When the parent is touched(The "magic" brick), begin the vanishing process! 

(Pardon the jokes. :P) Uh, yeah, please let me know how this works, and if I have made a sufficient answer. Also, to make this script work, you must put the following code in a script which is inside the brick you want to disappear. For example, say the brick was in workspace, it'd go like this: game<Workspace<The vanishing brick<Script, if you need any more help with this part, let me know. :) I also actually learnt what repeat loops are and how to use them too. Hah!

Apart from that, hope I helped!

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