duncan285
|
  |
| Joined: 20 Jun 2014 |
| Total Posts: 649 |
|
|
| 27 Dec 2015 05:17 PM |
does it make sense? okay here's my script:
game.Workspace.brick brick.Transparency.10 10=no transparency
end no
Transparency=barn barn.Workspace.55.intervals.brick.Transparency-.2
yeah it's for a first person shooter of mine is this good enough for the whole thing i mean can anybody revise it I think I did good on it tho |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:15 PM |
| I feel that you are leaving out some stuff, I think you just need to revise it, I looked at it, and I'm very confused, no offence. For example, change barn.Workspace to game.Workspace.barn |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:45 PM |
Yeeeeaah. I'm having trouble believing you're not trolling. But I suppose I'll give you the benefit of the doubt.
You know how on your computer, there are all sorts of folders, and inside those folders are files and more folders? If you think about it, it's kinda like a tree structure, where each file is a leaf, and each subfolder is a branch on its parent folder?
Roblox works pretty much the same. The trunk of the tree is called 'game'. One of the first branches on game is called 'Workspace'. To get from one branch (or the trunk) to one of it's children, you use the '.'. So game.Workspace would get you the workspace. If you've got something in the workspace (a part called "Part", for example), you can get it in the same way. game.Workspace.Part.
Many things in Roblox have properties, and you can change many of them. Even though you can't see the properties in the Explorer window, they behave much like branches and subbranches, in that you get them in the same way. A major difference is that you can set them, which is useful if you want to change something. To change a property of something (e.g. a part in Workspace called "Part"), you would do like this: game.Workspace.Part.Name = "Bob".
Typing out the full path of an instance can be a bother, so it's often very useful to store it as a variable. To store something in a variable, you just write the name of the variable, followed by an '=', followed by the value that you want the variable to hold. Example: name = game.Workspace.Part.Name. Keep in mind that if the name of the part later changes, the variable called "name" will NOT change with it.
How does all of this relate to what you're trying to do? Well, you want to make a part more transparent. Transparency is a property that all parts have, so we can use our knowledge about how to change properties to do just that. Transparency is measured on a scale of 0 to 1, where 0 is not transparent at all, and 1 is completely invisible. Example: game.Workspace.Part.Transparency = 0.5. This would make the part half transparent.
It seems like you want the part to gradually become more transparent over time. To do this, you can use a for loop. Put simply, a for loop does something a set number of times. Here's how you can use it: for i = 1, 10 do print(i) end. The first part just says "for", telling Roblox that what comes next is a for loop. Next we have something that looks like a variable definition, except there are two number value separated by a ','. What this means is that it will start by setting the variable i to 1, and then increase it by 1 until it reaches 10. The last part of the for loop is the "do end" part. You can put all sorts of code inside this part, and that code is run once every time the variable i increases. You can also give the for loop a third number, which defines how much is added to the variable each time. So for i = 0, 1, 1/50 do end will run the loop, increasing i by 1/50 each time until it reaches 1.
When you run a for loop, your computer tries to just do it all at once, without any delay. This is fine, but not what we want, since the brick needs to become more transparent over time. We can tell the script to slow down by calling the wait function. Example: for i = 0, 1, 1/50 do wait() end. This waits a small amount of time before repeating the loop.
Now you can make the loop turn your part invisible a bit at a time:
for i = 0, 1, 1/50 do game.Workspace.Part.Transparency = i end
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:47 PM |
"So for i = 0, 1, 1/50 do end will run the loop, increasing i by 1/50 each time until it reaches 1."
Yet another scripter overlooks that computers use base 2. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:49 PM |
> computers use base 2
So what? |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:53 PM |
Because 1/50 in base 2 is 0.0000 0101 0001 1110 1011 1000 0101 0001 1110 1011 1000 0101 001 which repeats infinitely, loses precision and becomes 0.019999999-ish. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:55 PM |
Somehow Lua deals nicely with it
for i = 0, 1, 1/5 do print(i) end
->
0.0 0.2 0.4 0.6 0.8 1.0
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 06:58 PM |
Sometimes. Other times not. I had to show people this on a couple of threads. Nobody else knew the answer because nobody else really notices it.
I have no idea how to find those threads, so I think this should suffice for the time being.
http://wiki.roblox.com/index.php/Lua_errors#Tricky_Mistakes
Yes, I understand that you are helping a beginner who doesn't need to be burdened with things that will only be necessary much later, but it bugged me. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 07:01 PM |
I know, but like I said Lua somehow (how? Beats me) deals with it
for n = 0, 0.9, 0.1 do print(n) end
->
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 07:02 PM |
I know, but like I said Lua somehow deals with it. It's apparently not a problem when using for loops.
for n = 0, 0.9, 0.1 do print(n) end
->
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 07:03 PM |
| Gold start for trying, forums. Tells me I'm posting too fast, but posts anyway <.< |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 07:14 PM |
I think the page may not have changed fast enough, and you clicked a second time before the page changed.
Yes, most of the time it will deal with it, but there are some occasions where it does not. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:17 PM |
| Well still, you can't say barn.Workspace, it's like saying Position.Jacob |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:18 PM |
| Oh, lol diremittens, first I thought you were duncan, and you thought I was trolling. |
|
|
| Report Abuse |
|
|