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 with a script

Previous Thread :: Next Thread 
ProSuperstar64 is not online. ProSuperstar64
Joined: 20 May 2012
Total Posts: 88
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 is online. 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
ProSuperstar64 is not online. ProSuperstar64
Joined: 20 May 2012
Total Posts: 88
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
thegoodpuppy is not online. thegoodpuppy
Joined: 07 Jul 2011
Total Posts: 2737
16 Oct 2016 03:31 PM
try GetChildren

Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
ProSuperstar64 is not online. ProSuperstar64
Joined: 20 May 2012
Total Posts: 88
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
16 Oct 2016 03:50 PM
fixed link:

http://wiki.roblox.com/index.php?title=Generic_for
Report Abuse
rapmilo is online. 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
mccrafter1212 is not online. mccrafter1212
Joined: 03 Jun 2014
Total Posts: 134
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 is online. 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
ProSuperstar64 is not online. ProSuperstar64
Joined: 20 May 2012
Total Posts: 88
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 is online. 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 is online. 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 is not online. 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
ProSuperstar64 is not online. ProSuperstar64
Joined: 20 May 2012
Total Posts: 88
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 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
16 Oct 2016 07:10 PM
i and v can be changed, yes
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
Flashiness is not online. Flashiness
Joined: 25 Dec 2012
Total Posts: 1212
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
ProSuperstar64 is not online. ProSuperstar64
Joined: 20 May 2012
Total Posts: 88
17 Oct 2016 09:35 PM
Ok, I see it now. Thanks again, guys.
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