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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 20 Mar 2012 |
| Total Posts: 9305 |
|
|
| 26 Feb 2015 09:06 AM |
| for _,child in pairs(target:GetChildren()) do * |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|