Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 09:35 AM |
function doorclosed() local DoorOpened = script.Parent.DoorOpened.GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false local DoorClosed = script.Parent.DoorClosed.GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true end end
function dooropened() local DoorOpened = script.Parent.DoorOpened.GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true local DoorClosed = script.Parent.DoorClosed.GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false end end
function click() local DC = script.Parent.DoorClosed local DO = script.Parent.DoorOpened
if DC.Part.Transparency == 0 then dooropened() wait(2) doorclosed() end end end end script.Parent.ClickDetector.MouseClick:connect(click)
Don't know what is wrong here... |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 09:36 AM |
| It means something doesn't exist |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 09:37 AM |
| But what? The GetChildren is suppose to find everything in the model right? And then the rest would go like that? |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 09:37 AM |
Basically instead of going
local DC = script.Parent.DoorClosed local DO = script.Parent.DoorOpened function click() if DC.Part1.CanCollide == true then -- Meaning it's closed --StartCanCollide-- DC.Part1.CanCollide = false DC.Part2.CanCollide = false DC.Part3.CanCollide = false DC.Part4.CanCollide = false DC.Part5.CanCollide = false DC.Part6.CanCollide = false DC.Part7.CanCollide = false DC.Part8.CanCollide = false DC.Part9.CanCollide = false DC.Part10.CanCollide = false DC.Part11.CanCollide = false DC.Window.CanCollide = false print 'DC CanCollide = False Complete' DO.Part1.CanCollide = true DO.Part2.CanCollide = true DO.Part3.CanCollide = true DO.Part4.CanCollide = true DO.Part5.CanCollide = true DO.Part6.CanCollide = true DO.Part7.CanCollide = true DO.Part8.CanCollide = true DO.Part9.CanCollide = true DO.Part10.CanCollide = true DO.Part11.CanCollide = true DO.Window.CanCollide = true print 'DO CanCollide = True Complete' --EndCanCollide--
--Start Transparency-- DC.Part1.Transparency = 1 DC.Part2.Transparency = 1 DC.Part3.Transparency = 1 DC.Part4.Transparency = 1 DC.Part5.Transparency = 1 DC.Part6.Transparency = 1 DC.Part7.Transparency = 1 DC.Part8.Transparency = 1 DC.Part9.Transparency = 1 DC.Part10.Transparency = 1 DC.Part11.Transparency = 1 DC.Window.Transparency = 1 print 'DC Transparency = 1 complete' DO.Part1.Transparency = 0 DO.Part2.Transparency = 0 DO.Part3.Transparency = 0 DO.Part4.Transparency = 0 DO.Part5.Transparency = 0 DO.Part6.Transparency = 0 DO.Part7.Transparency = 0 DO.Part8.Transparency = 0 DO.Part9.Transparency = 0 DO.Part10.Transparency = 0 DO.Part11.Transparency = 0 DO.Window.Transparency = 0.3 print 'DO Transparancy = 0 complete'
wait(3)
--StartCanCollide-- DC.Part1.CanCollide = true DC.Part2.CanCollide = true DC.Part3.CanCollide = true DC.Part4.CanCollide = true DC.Part5.CanCollide = true DC.Part6.CanCollide = true DC.Part7.CanCollide = true DC.Part8.CanCollide = true DC.Part9.CanCollide = true DC.Part10.CanCollide = true DC.Part11.CanCollide = true DC.Window.CanCollide = true print 'DC CanCollide = True Complete' DO.Part1.CanCollide = false DO.Part2.CanCollide = false DO.Part3.CanCollide = false DO.Part4.CanCollide = false DO.Part5.CanCollide = false DO.Part6.CanCollide = false DO.Part7.CanCollide = false DO.Part8.CanCollide = false DO.Part9.CanCollide = false DO.Part10.CanCollide = false DO.Part11.CanCollide = false DO.Window.CanCollide = false print 'DO CanCollide = false Complete' --EndCanCollide--
--Start Transparency-- DC.Part1.Transparency = 0 DC.Part2.Transparency = 0 DC.Part3.Transparency = 0 DC.Part4.Transparency = 0 DC.Part5.Transparency = 0 DC.Part6.Transparency = 0 DC.Part7.Transparency = 0 DC.Part8.Transparency = 0 DC.Part9.Transparency = 0 DC.Part10.Transparency = 0 DC.Part11.Transparency = 0 DC.Window.Transparency = 0.3 print 'DC Transparency = 0 complete' DO.Part1.Transparency = 1 DO.Part2.Transparency = 1 DO.Part3.Transparency = 1 DO.Part4.Transparency = 1 DO.Part5.Transparency = 1 DO.Part6.Transparency = 1 DO.Part7.Transparency = 1 DO.Part8.Transparency = 1 DO.Part9.Transparency = 1 DO.Part10.Transparency = 1 DO.Part11.Transparency = 1 DO.Window.Transparency = 1 print 'DO Transparancy = 1 complete'
end end script.Parent.ClickDetector.MouseClick:connect(click)
I want to shorten it to
function doorclosed() local DoorOpened = script.Parent.DoorOpened.GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false local DoorClosed = script.Parent.DoorClosed.GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true end end
function dooropened() local DoorOpened = script.Parent.DoorOpened.GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true local DoorClosed = script.Parent.DoorClosed.GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false end end
function click() local DC = script.Parent.DoorClosed local DO = script.Parent.DoorOpened
if DC.Part.Transparency == 0 then dooropened() wait(2) doorclosed() end end end end script.Parent.ClickDetector.MouseClick:connect(click) |
|
|
| Report Abuse |
|
|
Luc599345
|
  |
| Joined: 25 Jul 2008 |
| Total Posts: 1169 |
|
|
| 06 Jan 2013 10:00 AM |
You shouldn't do "script.Parent.DoorOpened.GetChildren()"
It should be : script.Parent.DoorOpened:GetChildren()
I didn't bother looking at the rest, it seems too long :/ |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 10:00 AM |
"attempt to call a nil value"
That means, that you are calling a function that doesn't exist. I'm currently busy, but its probably your connection line. |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 10:05 AM |
Changed it to :GetChildren(), still trying to call a nil value
function doorclosed() local DoorOpened = script.Parent.DoorOpened:GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false local DoorClosed = script.Parent.DoorClosed:GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true end end
function dooropened() local DoorOpened = script.Parent.DoorOpened:GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true local DoorClosed = script.Parent.DoorClosed:GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false end end
function click() local DC = script.Parent.DoorClosed local DO = script.Parent.DoorOpened
if DC.Part.Transparency == 0 then dooropened() wait(2) doorclosed() end end end end script.Parent.ClickDetector.MouseClick:connect(click)
Is it the child.Transparency line? If so how do I make it detect all the bricks in the model and then make it transparent. |
|
|
| Report Abuse |
|
|
Luc599345
|
  |
| Joined: 25 Jul 2008 |
| Total Posts: 1169 |
|
|
| 06 Jan 2013 10:06 AM |
| If you would tell us which line the output says it has an error, it'd be easier for all of us. |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 10:08 AM |
11:05:05 - attempt to call a nil value 11:05:05 - Disconnected event because of exception
^ That is all that comes up when I click on the door. |
|
|
| Report Abuse |
|
|
Luc599345
|
  |
| Joined: 25 Jul 2008 |
| Total Posts: 1169 |
|
|
| 06 Jan 2013 10:11 AM |
| Alright, I'll take a quick peek at it, but I need to know what the variable 'Part' is in this line : for index, child in pairs(Part) do |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 10:13 AM |
Model Layout
Model: Door Contents: DoorOpened, DoorClosed, ClickDetector, Script
Script
function doorclosed() local DoorOpened = script.Parent.DoorOpened:GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false local DoorClosed = script.Parent.DoorClosed:GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true end end
function dooropened() local DoorOpened = script.Parent.DoorOpened:GetChildren() for index, child in pairs(Part) do child.Transparency = 0 child.CanCollide = true local DoorClosed = script.Parent.DoorClosed:GetChildren() for index, child in pairs(Part) do child.Transparency = 1 child.CanCollide = false end end
function click() local DC = script.Parent.DoorClosed local DO = script.Parent.DoorOpened
if DC.Part.Transparency == 0 then dooropened() wait(2) doorclosed() end end end end script.Parent.ClickDetector.MouseClick:connect(click) |
|
|
| Report Abuse |
|
|
Luc599345
|
  |
| Joined: 25 Jul 2008 |
| Total Posts: 1169 |
|
|
| 06 Jan 2013 10:15 AM |
Sigh... I asked for what the 'Part' variable was, but I guess it doesn't exist so try this :
function doorclosed() local DoorOpened = script.Parent.DoorOpened:GetChildren() for index, child in pairs(DoorOpened) do child.Transparency = 1 child.CanCollide = false local DoorClosed = script.Parent.DoorClosed:GetChildren() for index, child in pairs(DoorClosed) do child.Transparency = 0 child.CanCollide = true end end
function dooropened() local DoorOpened = script.Parent.DoorOpened:GetChildren() for index, child in pairs(DoorOpened) do child.Transparency = 0 child.CanCollide = true local DoorClosed = script.Parent.DoorClosed:GetChildren() for index, child in pairs(DoorClosed) do child.Transparency = 1 child.CanCollide = false end end
function click() local DC = script.Parent.DoorClosed local DO = script.Parent.DoorOpened
if DC.Part.Transparency == 0 then dooropened() wait(2) doorclosed() end end end end script.Parent.ClickDetector.MouseClick:connect(click) |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 10:19 AM |
Oh sorry, Part is in the DoorOpened and DoorClosed model, it's the name of every part that makes up the door ( About 30 parts )
Also, the script you made just now gave the same error. |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
| |
|
|
| 06 Jan 2013 11:46 AM |
Ugh... Luc said that Part doesn't exist... which basically means that you didn't put "Part" as a variable, so it's not working because "Part" is a nil value.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 11:50 AM |
| But part is in the model the GetChildren is searching... |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 11:52 AM |
If part is in the model, you'd have to do something like this:
for _, v in pairs(script.Parent.Parent.Parent.Parent.Part:GetChildren()) do
Basically, you just find where "Part" is, and you get it's children.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 11:53 AM |
| Use Luc's. I was gonna post the same thing. You didn't have the enhanced for loop setup right. |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 11:57 AM |
Luc's didn't work
The script is suppose to find all the parts named part in the model, and make them all transparent when you click it. |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 12:01 PM |
for _, v in pairs(model:GetChildren()) do if v:IsA("Part") then v.Transparency = 1 wait() end end
Didn't bother to read the script because it was too long, but this is the basic idea of it.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 06 Jan 2013 12:06 PM |
Tried it
function open() for _, v in pairs(script.Parent.DoorClosed:GetChildren()) do if v:IsA("Part") then v.Transparency = 1 v.CanCollide = true wait() end end
function close() for _, v in pairs(script.Parent.DoorOpened:GetChildren()) do if v:IsA("Part") then v.Transparency = 1 v.CanCollide = true wait() end end
function open2() for _, v in pairs(script.Parent.DoorClosed:GetChildren()) do if v:IsA("Part") then v.Transparency = 0 v.CanCollide = false wait() end end
function close2() for _, v in pairs(script.Parent.DoorOpened:GetChildren()) do if v:IsA("Part") then v.Transparency = 0 v.CanCollide = false wait() end end
function click() open2() close() wait(2) open() close2() end end end end end script.Parent.ClickDetector.MouseClick:connect(click)
Didn't work, same error.
13:05:51 - attempt to call a nil value 13:05:51 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
| |
|
|
| 06 Jan 2013 04:21 PM |
is doorclosed() and click() a function?
if they aren't, that might be a problem |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 05:51 PM |
Try this:
function open() for _, v in pairs(script.Parent.DoorClosed:GetChildren()) do if v:IsA("Part") then v.Transparency = 1 v.CanCollide = true wait() end end end
function close() for _, v in pairs(script.Parent.DoorOpened:GetChildren()) do if v:IsA("Part") then v.Transparency = 1 v.CanCollide = true wait() end end end
function open2() for _, v in pairs(script.Parent.DoorClosed:GetChildren()) do if v:IsA("Part") then v.Transparency = 0 v.CanCollide = false wait() end end end
function close2() for _, v in pairs(script.Parent.DoorOpened:GetChildren()) do if v:IsA("Part") then v.Transparency = 0 v.CanCollide = false wait() end end end
function click() open2() close() wait(2) open() close2() end
script.Parent.ClickDetector.MouseClick:connect(click)
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2013 06:12 PM |
| It doesn't work because You have your ends all mixed up. |
|
|
| Report Abuse |
|
|