|
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
|
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
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
|
|
UFAIL2Join Date: 2010-08-14 Post Count: 6905 |
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'.~ |
|
C0D3YJoin Date: 2010-07-24 Post Count: 1692 |
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? |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
@UFAIL2
I already told you this before, his script is more efficient than yours by .002%. Yours is just less coding. |
|
UFAIL2Join Date: 2010-08-14 Post Count: 6905 |
@COD3Y
http://wiki.roblox.com/index.php/Variable#Local_Variables
~When life gives you lemons, you say 'I ain't even mad'.~ |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
@C0dy
I didn't end the scope, if I did end the scope than yeah, I can't use deb anymore. |
|
UFAIL2Join Date: 2010-08-14 Post Count: 6905 |
@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'.~ |
|
grimm343Join Date: 2008-09-18 Post Count: 2796 |
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 |
|
grimm343Join Date: 2008-09-18 Post Count: 2796 |
Looping for a .Touched is odd.. I shall avoid it like a minor plague. >.> |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
@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. |
|
|
@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 |
|
|
@Miz
Your script didn't work... I tried it but nothing happends... |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
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
|
|
grimm343Join Date: 2008-09-18 Post Count: 2796 |
What was wrong with mine? D: I just made those many, many lines into two small loops. o.O |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
Maybe he doesn't get loops... |
|
stravantForum ModeratorJoin Date: 2007-10-22 Post Count: 2893 |
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. |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
@stravant
Isn't an event more efficient then a while loop though? |
|
stravantForum ModeratorJoin Date: 2007-10-22 Post Count: 2893 |
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. |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
Ah, ok. But what about the for loop? Some people told me that that's less efficient then just running the whole code. |
|
stravantForum ModeratorJoin Date: 2007-10-22 Post Count: 2893 |
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. |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
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.) |
|
|
@miz656
I doubt people like kingkiller1000 would say a such thing.
You probably understood them wrong. |
|
miz656Join Date: 2010-07-19 Post Count: 15336 |
@julien
I remember kingkiller1000 said that to me. Though, he said it was efficient by .0002% So did spectrumz. |
|
|
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. |
|