|
| 16 Oct 2016 01:57 PM |
Its rather simple, but I want a script that makes all the parts under a parent in the workspace to become invisible when a game starts.
So far I have: local part part.transparency = 1 end
I need to tell the script to do that to all parts within the parent. |
|
|
| Report Abuse |
|
|
rapmilo
|
  |
| Joined: 16 Aug 2011 |
| Total Posts: 69 |
|
|
| 16 Oct 2016 02:49 PM |
| You haven't defined part. Try it like this local part=script.Parent |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 03:29 PM |
Ok, so now I have: part = script.Parent local part part.transparency = 1 end
It still doesn't make the parts invisible. |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 03:30 PM |
Why did you put a random 'end' there?
end should only be used when ending any of the following statements:
if for while function
|
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Oct 2016 03:32 PM |
or do statements as well
point is: dont put an 'end' when you have literally nothing to end |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 03:41 PM |
I had an end there from trying a "while true do" before posting this topic. Tried it without the end. No results. Tried GetChildren. No results.
Now I have: part = script.Parent:GetChildren() local part part.transparency = 1 |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 03:46 PM |
http://wiki.roblox.com/index.php?title=Generic_For
http://wiki.roblox.com/index.php?title=Table |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 03:50 PM |
fixed link:
http://wiki.roblox.com/index.php?title=Generic_for |
|
|
| Report Abuse |
|
|
rapmilo
|
  |
| Joined: 16 Aug 2011 |
| Total Posts: 69 |
|
|
| 16 Oct 2016 04:11 PM |
Try this: local part = script.Parent:GetChildren() --Make the parent an entire model with all the parts in it function (onTouch() print("Script works") --precaution part.transparency = 1 end script.Parent.Touched:connect(onTouch)
Tell me if this works...if not tell me the output. |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 04:14 PM |
for i,v in pairs(game.Workspace:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") then v.Transparency = 1 end end |
|
|
| Report Abuse |
|
|
rapmilo
|
  |
| Joined: 16 Aug 2011 |
| Total Posts: 69 |
|
|
| 16 Oct 2016 04:23 PM |
| Oops. Follow the script by the post above me. This should be in a loop not a function. |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 04:50 PM |
mccrafter1212's suggestion did work, just not in the way I intended to. Instead all the parts in Workspace were made invisible.
I should mention that the script is located inside the parent (Collision), with the parts. Workspace, Ladder, Collision Not sure if this matters, but Ladder is a model and Collision is a folder. |
|
|
| Report Abuse |
|
|
rapmilo
|
  |
| Joined: 16 Aug 2011 |
| Total Posts: 69 |
|
|
| 16 Oct 2016 05:56 PM |
| You need to change the for loop here so that it specifies on to your specific part. for i,v in pairs(game.Workspace:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") then v.Transparency = 1 end end Above is the original code. What you want to do is add to the first line after .Workspace by continuing with the Parent that you described. I suggest you put your script in the Parent under which all #### ##### are. If you do it this way this script should work: for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") then v.Transparency = 1 end end |
|
|
| Report Abuse |
|
|
rapmilo
|
  |
| Joined: 16 Aug 2011 |
| Total Posts: 69 |
|
|
| 16 Oct 2016 05:58 PM |
Here is a neater version of my earlier message:
You need to change the for loop here so that it specifies on to your specific part.
for i,v in pairs(game.Workspace:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") then v.Transparency = 1 end end
Above is the original code. What you want to do is add to the first line after .Workspace by continuing with the Parent that you described. I suggest you put your script in the Parent under which all of your union/parts are. If you do it this way this script should work:
for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") then v.Transparency = 1 end end |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 16 Oct 2016 06:08 PM |
If you just want the 'part' to be changed, you'll need to change the part's transparency.
If you actually look in the properties of the part, 'Transparency' is capitalized.
You can't just assume that the computer knows what 'part' is.
So:
local part = script.Parent -- assuming the script is in the part part.Transparency = 1 -- notice the capital 'T'? |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 07:08 PM |
caca, the point of this script was so I didn't have to have an individual script in each part that needed to be modified. But thanks for catching that small error for me!
Otherwise, it worked! Thank you guys so much! I just have one more question, what does 'i' and 'v' mean in the script? Are these just variable names that I can change? |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 16 Oct 2016 07:10 PM |
| i and v can be changed, yes |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 07:13 PM |
i and v are both variables
it is like saying
for key,value in ipairs(workspace:getChildren()) do print(key,value) end
local key = 1 local tbl = workspace:getChildren() while tbl[key] do local value = tbl[key] print(key,value) key=key+1 end |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2016 07:21 PM |
| its a recursive loop. you're looping through a table. i is the position in the table and v is the thing in that position. |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2016 09:35 PM |
| Ok, I see it now. Thanks again, guys. |
|
|
| Report Abuse |
|
|