|
| 07 Jul 2013 01:16 AM |
I'm not EXACTLY sure how everything goes just yet. I'm following the instructions from
http://wiki.roblox.com/index.php/Absolute_beginner's_guide_to_scripting#Before_proceeding...
to make a script in which a brick goes away. I'm not sure exactly how it's all supposed to work either, so I'm gonna address my other questions aswell on the thread. So the script I have now is
local brick = Workspace.Brick2 <-- This means that I use brick instead of Workspace.Brick2 whenever I intend to specify Brick2, correct? function onTouch(part) <-- is onTouch an actual command within Lua? Could it have been something else with the same outcome? brick.Transparency = 1<---- wait(1) ---- This all means that whenever a part, even a character like my own, a Robloxian, able to trigger the effect? brick.Transparency = 0 <--- end brick.Touched:connect(onTouch)
Basically, if you take out all that question mumbo jumbo, my whole script right now is
local brick = Workspace.Brick2 function onTouch(part) brick.Transparency = 1 wait(1) brick.Transparency = 0 end brick.Touched:connect(onTouch)
Would the script still work in this fashion?
local brick = Workspace.Brick2 brick.Touched:connect(onTouch)
function onTouch(part) brick.Transparency = 1 wait(1) brick.Transparency = 0 end
So basically, the problem I really made this thread for, was due to I'm not sure exactly when the changes take place. I added the script into Workspace (via right click workspace --> insert into from file --> selecting the .txt) and it doesn't seem to actually make the brick (which is conveniently also a brick) go transparent. How do I make the eventhandler take event upon startup of the server? On Roblox studio, I create a Brick (which is by default called Brick2 on the Explorer) and I jump onto it. There is no effect on the brick whatsoever. Must I start an actual match for the changes to take effect? I'm not sure if I'm doing something wrong.
Much Appreciated! |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:22 AM |
| Okay, I've gotten PART of the block to go invisible. The side I touch and the side to the right of the side I touched do not go invisible. It appears to onlywork whenever I select the specific brick. How would I go about making it disappear without me having to select it? As in, any random guy touching it without doing anything special would make it disappear. |
|
|
| Report Abuse |
|
|
Joalmo
|
  |
| Joined: 28 Jun 2009 |
| Total Posts: 1160 |
|
|
| 07 Jul 2013 01:28 AM |
local brick = Workspace.Brick2 local debounce = false
script.Parent.Touched:connect(function() if not debounce then debounce = true brick.Transparency = 1 wait(1) debounce = false brick.Transparency = 0 end end)
Put that inside the brick you touch, I think this script will work better for what you're doing |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:32 AM |
I appreciate the help, but since I'm a newbie on this topic I need to actually understand what that all means.
local brick = Workspace.Brick2 local debounce = false <-- Why is it false and what is debounce?
script.Parent.Touched:connect(function() <-- by (function() can I put my own word instead of function, or is that vital to the script? if not debounce then debounce = true brick.Transparency = 1 wait(1) debounce = false brick.Transparency = 0 end |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:37 AM |
Hi, kitty. I'm even more of a newb scripter, lol.
But debounce is the property to make sure your script finishes running through before it repeats the process.
It is most common in touched events, which is the kind of even you happen to be doing right now.
If someone tries to touch your brick, the connection could happen multiple times. A debounce inserted into that script will only make a script run once instead of running the multiple times it has been activated.
Did that make any sense? |
|
|
| Report Abuse |
|
|
Joalmo
|
  |
| Joined: 28 Jun 2009 |
| Total Posts: 1160 |
|
|
| 07 Jul 2013 01:38 AM |
debounce makes it so the code inside the function runs once when the Touched event fires, and not a bunch of times. Search "debounce" on the wiki for a better explanation.
And no, I used an anonymous function for that. So instead of defining the onTouch() function and calling it later in the script, we can just have an unnamed function that gets called when the Touched event fires. Again, the wiki page on "Anonymous Functions" will help.
Sorry for the poor explanations, I'm entering full sleep deprivation and typing this on my iPod. |
|
|
| Report Abuse |
|
|
Joalmo
|
  |
| Joined: 28 Jun 2009 |
| Total Posts: 1160 |
|
|
| 07 Jul 2013 01:39 AM |
| Burnout, debounce is a Boolean variable, not a property. |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:40 AM |
| Sorry, I only know some terms. I thought boolean values were just true and false. |
|
|
| Report Abuse |
|
|
Joalmo
|
  |
| Joined: 28 Jun 2009 |
| Total Posts: 1160 |
|
|
| 07 Jul 2013 01:41 AM |
debounce = true debounce = false
True and false, Boolean variable :p |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:41 AM |
| Thanks for the help, both. I see what debounce is now. I'm not familiar with 'boolean.' Is it possible to explain what a boolean is in newbie language? Also, thanks for giving me that code. Do I have to paste it in every single brick that fits the specifications of the script? By the way, I'm still having the problem of whatever side I run into, aswell as the side to the right of it, stay visible despite the rest of the block being invisible. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Jul 2013 01:43 AM |
#KittyLover,
According to Stickmasterluke, most boolean values can be visualized as some "checkboxes" you might see under a part's properties. He said true/false could also symbolize checking and unchecking a checkbox visually.
I still don't know if that had made any sense. |
|
|
| Report Abuse |
|
|
Joalmo
|
  |
| Joined: 28 Jun 2009 |
| Total Posts: 1160 |
|
|
| 07 Jul 2013 01:47 AM |
Boolean values are just true/false values.
x = 6 --integer variable y = false --Boolean variable
I'm not quite sure what you mean by "fits the specifications of the script", but any other brick you put the script in will also cause "Brick2" to become transparent for 1 second when touched.
And about the 1-sided non-transparent thing, I feel like that's some kind of bug or something along those lines. I'm not sure though, but it shouldn't be happening. |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:48 AM |
Uhm. For example,
If you change the properties on a baseplate, you would:
Workspace > Baseplate
Then go to the baseplate's properties and scroll down to "Behavior."
If you wanted to unanchor your baseplate, you could go down and uncheck Anchored.
To do this through script, you use boolean values.
Instead of unchecking the box, you could:
game.Workspace.Baseplate.Anchored = false
and if the game is running, your baseplate would drop out of the sky. |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 01:58 AM |
I knew that much. x3
Thanks for the help! |
|
|
| Report Abuse |
|
|
Joalmo
|
  |
| Joined: 28 Jun 2009 |
| Total Posts: 1160 |
|
| |
|
|
| 07 Jul 2013 02:00 AM |
| No problem. Did your solution work? |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2013 02:36 AM |
My solution? Also, this thread will probably grow pretty big since I have lots of questions. I'm pretty focused on actually becoming a decent Lua scripter (I've tried before. I forgot the next day xD)
function twoPlusTwo() -- Function name <--- What's up iwth the parentheses here? x = 2 + 2 -- Variable print(x) -- Print variable's value end -- End twoPlusTwo() -- This is how you call a function. Once called it will run your block of code from before.
Calling a function? How do you call a function? By that, if I type in twoPlusTwo() into chat it will run the function? Also, what's up with the parentheses there? Basically, what's the purpose of having the parentheses? |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Jul 2013 03:28 AM |
| I think the parenthesis are to show that it's a function and are used as activators. |
|
|
| Report Abuse |
|
|
| |
|