Honorem
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 209 |
|
|
| 12 Aug 2015 03:00 PM |
Alright, so I'm just learning lua. I'm trying to make disappearing blocks in an obby. I know this code is probably completely wrong(Teaching lua to myself), but here is the script that's in the brick. b = script.Parent if b.Transparency=1 then wait(2) b.Transparency=0 end if b.Transparency=0 then wait(2) b.Transparency=1 end
I want the block to disappear, then reappear. I want that to loop. Any help? |
|
|
| Report Abuse |
|
|
Honorem
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 209 |
|
|
| 12 Aug 2015 03:01 PM |
Sorry, pasted the wrong code. This is my code -
b = script.Parent if b.Transparency=0 then wait(2) b.Transparency=1 end if b.Transparency=1 then wait(2) b.Transparency=0 end |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2015 03:08 PM |
| where is the script located |
|
|
| Report Abuse |
|
|
Honorem
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 209 |
|
|
| 12 Aug 2015 03:11 PM |
| It's kind of deep, working on a holo training area. It's in workspace-->part--->part-->part |
|
|
| Report Abuse |
|
|
Burglered
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 962 |
|
|
| 12 Aug 2015 03:15 PM |
while wait(2) do b.Transparency = 0 wait(2) b.Transparency = 1 end
Flash Drives are Floppy Disks. Floppy Disks are SD Cards. |
|
|
| Report Abuse |
|
|
Rxhan
|
  |
| Joined: 09 Oct 2010 |
| Total Posts: 252 |
|
|
| 12 Aug 2015 03:16 PM |
insert the script into each brick.
you're gonna want to learn loops and functions :
function() while true do local b = script.Parent if b.Transparency = 0 then wait(2) b.Transparency = 1
end end
function()
this might be right, but it also might not be right bc i am also a bit rusty on scripting after my break from roblox.
r.i.p 5k+ posts ;( |
|
|
| Report Abuse |
|
|
Rxhan
|
  |
| Joined: 09 Oct 2010 |
| Total Posts: 252 |
|
|
| 12 Aug 2015 03:17 PM |
do you want it to disappear when touched? or just disappear every 2 secs then reappear?
if it's the disappear every 2 secs thing then the script above should work, just insert it into the part.
r.i.p 5k+ posts ;( |
|
|
| Report Abuse |
|
|
Rxhan
|
  |
| Joined: 09 Oct 2010 |
| Total Posts: 252 |
|
|
| 12 Aug 2015 03:17 PM |
oops, i mean
function() while true do local b = script.Parent if b.Transparency = 0 then wait(2) b.Transparency = 1 wait(2) b.Transparency = 0
end end
function()
this might be right, but it also might not be right bc i am also a bit rusty on scripting after my break from roblox.
r.i.p 5k+ posts ;( |
|
|
| Report Abuse |
|
|
Burglered
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 962 |
|
|
| 12 Aug 2015 03:19 PM |
@Rxhan
it doesn't check if the transparency is 1 so it won't change back.
Flash Drives are Floppy Disks. Floppy Disks are SD Cards. |
|
|
| Report Abuse |
|
|
Burglered
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 962 |
|
|
| 12 Aug 2015 03:19 PM |
nevermind
Flash Drives are Floppy Disks. Floppy Disks are SD Cards. |
|
|
| Report Abuse |
|
|
Rxhan
|
  |
| Joined: 09 Oct 2010 |
| Total Posts: 252 |
|
|
| 12 Aug 2015 03:19 PM |
i fixed it.
r.i.p 5k+ posts ;( |
|
|
| Report Abuse |
|
|
Honorem
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 209 |
|
|
| 12 Aug 2015 03:24 PM |
Thanks for the help guys.
Just confused on where to put your code, burglered.
This does NOT work.
b=script.Parent if b.Transparency=0 then wait(2) b.Transparency=1 end if b.Transparency=1 then wait(2) b.Transparency=0 end while wait(2) do b.Transparency = 0 wait(2) b.Transparency = 1 end
Although I'm sure I put it in the wrong place.. |
|
|
| Report Abuse |
|
|
Honorem
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 209 |
|
|
| 12 Aug 2015 03:52 PM |
Nevermind, I got it.
I used:
b = script.Parent
while true do wait(2) b.Transparency = 0.2 wait(0.1) b.Transparency = 0.4 wait(0.1) b.Transparency = 0.6 wait(0.1) b.Transparency = 0.8 wait(0.1) b.Transparency = 1 b.CanCollide = true wait(2) b.Transparency = 1 wait(0.1) b.Transparency = 0.8 wait(0.1) b.Transparency = 0.6 wait(0.1) b.Transparency = 0.4 wait(0.1) b.Transparency = 0.2 wait(0.1) b.Transparency = 0 b.CanCollide = false end
Just added the 0.1 second wait for the vanishing effect, i like it :) Thank you all for the help! |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 12 Aug 2015 03:54 PM |
Good god. Learn how to use loops.
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
Honorem
|
  |
| Joined: 17 Sep 2010 |
| Total Posts: 209 |
|
|
| 13 Aug 2015 10:38 PM |
| @TimeTicks as i said, I am NEW to scripting. I do not know how to use loops. That is why I am posting on here. If I did, I would not be posting here. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2015 11:40 PM |
" while true do wait(2) b.Transparency = 0.2 wait(0.1) b.Transparency = 0.4 wait(0.1) b.Transparency = 0.6 wait(0.1) b.Transparency = 0.8 wait(0.1) b.Transparency = 1 b.CanCollide = true wait(2) b.Transparency = 1 wait(0.1) b.Transparency = 0.8 wait(0.1) b.Transparency = 0.6 wait(0.1) b.Transparency = 0.4 wait(0.1) b.Transparency = 0.2 wait(0.1) b.Transparency = 0 b.CanCollide = false end "
This can be much more effecient and way less ugly! http://wiki.roblox.com/index.php?title=Loops#For
for i=1, 10 do part.Transparency=i/10 wait(0.1) end |
|
|
| Report Abuse |
|
|