of     2   
chevron_rightchevron_rightchevron_right

ImmortalMiner
#63421168Saturday, February 25, 2012 4:55 PM GMT

for i, v in pairs(workspace:GetChildren()) do if v.Name == "DissapearingJump" then v.Touched:connect(function(hit)) wait(.001) v.Transparency = .1 wait(.1) v.Transparency = .2 wait(.1) v.Transparency = .3 wait(.1) v.Transparency = .4 wait(.1) v.Transparency = .5 wait(.1) v.Transparency = .6 wait(.1) v.Transparency = .7 wait(.1) v.Transparency = .8 wait(.1) v.Transparency = .9 wait(.1) v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 1 wait(.01) v.Transparency = .9 wait(.01) v.Transparency = .8 wait(.01) v.Transparency = .7 wait(.01) v.Transparency = .6 wait(.01) v.Transparency = .5 wait(.01) v.Transparency = .4 wait(.01) v.Transparency = .3 wait(.01) v.Transparency = .2 wait(.01) v.Transparency = .1 wait(.01) v.Transparency = 0 v.CanCollide = true end) end end
miz656
#63421396Saturday, February 25, 2012 4:58 PM GMT

local deb = true for i, v in pairs(workspace:GetChildren()) do if v.Name == "DissapearingJump" then v.Touched:connect(function(hit)) if deb == true then deb = false wait(.001) v.Transparency = .1 wait(.1) v.Transparency = .2 wait(.1) v.Transparency = .3 wait(.1) v.Transparency = .4 wait(.1) v.Transparency = .5 wait(.1) v.Transparency = .6 wait(.1) v.Transparency = .7 wait(.1) v.Transparency = .8 wait(.1) v.Transparency = .9 wait(.1) v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 1 wait(.01) v.Transparency = .9 wait(.01) v.Transparency = .8 wait(.01) v.Transparency = .7 wait(.01) v.Transparency = .6 wait(.01) v.Transparency = .5 wait(.01) v.Transparency = .4 wait(.01) v.Transparency = .3 wait(.01) v.Transparency = .2 wait(.01) v.Transparency = .1 wait(.01) v.Transparency = 0 v.CanCollide = true wait(5) deb = true end end) end end
UFAIL2
#63421513Saturday, February 25, 2012 5:00 PM GMT

Inefficiency at it's worst. Allow = true for i, v in pairs(Workspace:GetChildren()) do if v.Name == "DissapearingJump" then v.Touched:connect(function(hit) if Allow then Allow = false wait() for i = 0, 1, 0.1 do v.Transparency = i wait(0.01) end v.CanCollide = false wait(5) for i = 1, 0, -0.1 do v.Transparency = i wait(0.01) end v.CanCollide = true end end) end end ~When life gives you lemons, you say 'I ain't even mad'.~
C0D3Y
#63421531Saturday, February 25, 2012 5:00 PM GMT

Um, Miz, I know you're a lot better at scripting than me so feel free to tell me if I'm wrong but if you use a local variable, won't it only work inside the function it's in?
miz656
#63421592Saturday, February 25, 2012 5:01 PM GMT

@UFAIL2 I already told you this before, his script is more efficient than yours by .002%. Yours is just less coding.
UFAIL2
#63421630Saturday, February 25, 2012 5:02 PM GMT

@COD3Y http://wiki.roblox.com/index.php/Variable#Local_Variables ~When life gives you lemons, you say 'I ain't even mad'.~
miz656
#63421651Saturday, February 25, 2012 5:02 PM GMT

@C0dy I didn't end the scope, if I did end the scope than yeah, I can't use deb anymore.
UFAIL2
#63421684Saturday, February 25, 2012 5:03 PM GMT

@miz I aim for less lines, and making the script look clean; don't you? ~When life gives you lemons, you say 'I ain't even mad'.~
grimm343
#63421760Saturday, February 25, 2012 5:04 PM GMT

Pause time. Put the following in a Script named 'spt' in Workspace. db = false script.Parent.Touched:connect(function(h) if db then return end db = true for i=0,1,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = false wait(3) for i=1,0,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = true db = false end) Then, copy the following line and put it into the Command line, and hit your enter/return key. for _,v in pairs(Workspace:children()) do if v.Name == "DissapearingJump" then Workspace.spt:Clone().Parent = v end end
grimm343
#63421822Saturday, February 25, 2012 5:04 PM GMT

Looping for a .Touched is odd.. I shall avoid it like a minor plague. >.>
miz656
#63421896Saturday, February 25, 2012 5:06 PM GMT

@UFAIL2 I don't really care if a script is efficient or not. I would rather want it to be inefficient and make it work then to be efficient but not work, no output and feel stress. Point is, I don't care, my goal to scripting is making it work, not being stressed over efficiency.
ImmortalMiner
#63422042Saturday, February 25, 2012 5:08 PM GMT

@Miz I just used yours... It looks like the simplest way out of everyones script here... And I can actually tell what it does =P
ImmortalMiner
#63422278Saturday, February 25, 2012 5:11 PM GMT

@Miz Your script didn't work... I tried it but nothing happends...
miz656
#63422611Saturday, February 25, 2012 5:16 PM GMT

local deb = true for i, v in pairs(workspace:GetChildren()) do if v.Name == "DissapearingJump" and deb == true then v.Touched:connect(function(hit)) deb = false wait(.001) v.Transparency = .1 wait(.1) v.Transparency = .2 wait(.1) v.Transparency = .3 wait(.1) v.Transparency = .4 wait(.1) v.Transparency = .5 wait(.1) v.Transparency = .6 wait(.1) v.Transparency = .7 wait(.1) v.Transparency = .8 wait(.1) v.Transparency = .9 wait(.1) v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 1 wait(.01) v.Transparency = .9 wait(.01) v.Transparency = .8 wait(.01) v.Transparency = .7 wait(.01) v.Transparency = .6 wait(.01) v.Transparency = .5 wait(.01) v.Transparency = .4 wait(.01) v.Transparency = .3 wait(.01) v.Transparency = .2 wait(.01) v.Transparency = .1 wait(.01) v.Transparency = 0 v.CanCollide = true wait(5) deb = true end) end end
grimm343
#63430438Saturday, February 25, 2012 7:29 PM GMT

What was wrong with mine? D: I just made those many, many lines into two small loops. o.O
miz656
#63433891Saturday, February 25, 2012 8:34 PM GMT

Maybe he doesn't get loops...
stravant
Forum Moderator
#63434180Saturday, February 25, 2012 8:39 PM GMT

If you want to see a novel way to re-write the script without needing a debounce at all, then you can do it like this too: while true do local h = script.Parent.Touched:wait() for i=0,1,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = false wait(3) for i=1,0,.1 do script.Parent.Transparency = i wait() end script.Parent.CanCollide = true end Putting stuff in that form can actually make a lot of situations a lot easier to deal with.
miz656
#63434708Saturday, February 25, 2012 8:48 PM GMT

@stravant Isn't an event more efficient then a while loop though?
stravant
Forum Moderator
#63436039Saturday, February 25, 2012 9:11 PM GMT

No, because the loop isn't continually running. The Event:wait() syntax tells Roblox not to run the script again until the event has happened.
miz656
#63436272Saturday, February 25, 2012 9:16 PM GMT

Ah, ok. But what about the for loop? Some people told me that that's less efficient then just running the whole code.
stravant
Forum Moderator
#63437751Saturday, February 25, 2012 9:42 PM GMT

They're wrong. Loops have nothing inherently wrong with them, its only when you run code with them every single frame that you have to be careful.
miz656
#63443757Saturday, February 25, 2012 11:27 PM GMT

No, like for example This script script.Parent.Transparency = 1 wait(1) script.Parent.Transparency = .9 wait(1) script.Parent.Transparency = .8 --And so on To this script for i = 1,0,-.1 do wait(1) script.Parent.Transparency = i end They say the first script is more efficient then the second. And the people who say that are master scripters, like kingkiller1000. (Sorry if I messed up the for loop, said it wrong. I was in a hurry.)
JulienDethurens
#63444586Saturday, February 25, 2012 11:43 PM GMT

@miz656 I doubt people like kingkiller1000 would say a such thing. You probably understood them wrong.
miz656
#63445813Sunday, February 26, 2012 12:04 AM GMT

@julien I remember kingkiller1000 said that to me. Though, he said it was efficient by .0002% So did spectrumz.
JulienDethurens
#63446136Sunday, February 26, 2012 12:10 AM GMT

Efficiency isn't only speed, it also includes many other things, they're wrong. As for speed, well, there isn't any difference on ROBLOX. There are many factors that will make speed be completely independant as to which of these you use.

    of     2   
chevron_rightchevron_rightchevron_right