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
 

Help with simple 1 line script please

Previous Thread :: Next Thread 
Iarrysad is not online. Iarrysad
Joined: 02 Dec 2012
Total Posts: 191
26 Feb 2015 08:50 AM
This is the script

script.Parent.Main.Anchored = true



But how do I make it so that "main" can be more than 1 part Like so it detects "main AND another parts name" - "Main and Main1 and Main2"
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
26 Feb 2015 08:57 AM
use :GetChildren() and use a for loop

e.i

local model = game.Workspace:GetChildren()
for i = 1,#model do
model[i].Anchored = true
end
Report Abuse
Skyman772 is not online. Skyman772
Joined: 20 Mar 2012
Total Posts: 9305
26 Feb 2015 08:59 AM
Use tables like this!

local partTable = {
"Main";
"Main1";
"Main2";
}

function AnchorParts(table,parent) do
for _,part in pairs(table) do
local part = parent:FindFirstChild(part)
if part ~= nil then
part.Anchored = true
end
end
end

AnchorParts(partTable,script.Parent)
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
26 Feb 2015 09:03 AM
My way is better bc then you can do 100000 parts and not make a big table
Report Abuse
Skyman772 is not online. Skyman772
Joined: 20 Mar 2012
Total Posts: 9305
26 Feb 2015 09:06 AM
I did it in to meet the needs of what the guy wanted - he wanted it to involve the part's name.

Optimally, I'd do it like this.

local function AnchorParts(target)
for _,child in pairs(target) do
if child:IsA("Part") then
child.Anchored = true
end
end
end

AnchorParts(game.Workspace)
Report Abuse
Skyman772 is not online. Skyman772
Joined: 20 Mar 2012
Total Posts: 9305
26 Feb 2015 09:06 AM
for _,child in pairs(target:GetChildren()) do *
Report Abuse
Iarrysad is not online. Iarrysad
Joined: 02 Dec 2012
Total Posts: 191
26 Feb 2015 09:40 AM
Well how would you add that into this script?



open = false

wait(0.1)

script.Parent.Main.Anchored = true

function onClicked()
if script.Parent.OPEND.Value == 1 then

if open == false then
script.Parent.Main.Anchored = true
cfr = script.Parent.Main.CFrame
open = true
for i = 0,1.5,0.1 do
wait(0.2)
script.Parent.Main.CFrame = script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25)
end
script.Parent.Main.CFrame = cfr*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5)
script.Parent.Main.Anchored = true
open = false
script.Parent.OPEND.Value = 0
end
elseif script.Parent.OPEND.Value == 0 then

if open == false then
script.Parent.Main.Anchored = true
cfr = script.Parent.Main.CFrame
open = true
for i = 0,1.5,0.1 do
wait(0.01)
script.Parent.Main.CFrame = script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25)
end
script.Parent.Main.CFrame = cfr*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5)
script.Parent.Main.Anchored = true
open = false
script.Parent.OPEND.Value = 1
end

end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
26 Feb 2015 09:45 AM
I'll go make the changes.

Translation of the above statement:
This spot is reserved for JarodOfOrbiter's glory - nobody else is allowed to do it before him.
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
26 Feb 2015 09:48 AM
Wait, do you really scripted it that much and cant solve that one line?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
26 Feb 2015 09:53 AM
Actually never mind. You should just group all of the parts into a model and use SetPrimaryPartCFrame after setting the PrimaryPart with a script. It will work almost perfectly with your current script.
Report Abuse
Iarrysad is not online. Iarrysad
Joined: 02 Dec 2012
Total Posts: 191
26 Feb 2015 09:58 AM
could I do like

poop = script.Parent.Main

and have "main" a model?
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