generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Need help, new to scripting

Previous Thread :: Next Thread 
Honorem is not online. 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 is not online. 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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
12 Aug 2015 03:08 PM
where is the script located
Report Abuse
Honorem is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image