Gofven
|
  |
| Joined: 18 Jun 2015 |
| Total Posts: 767 |
|
|
| 19 Sep 2016 01:48 AM |
Well for some strange reason my script doesn't work if _G.Tc1TrainDoorsShut = false, I wonder why? The thing that happens is all parts and objects just gets non-existent.
local D = game.Workspace.Train.Triggers.Doors _G.Tc1TrainDoorsShut = true local D1 = D.D1 local D2 = D.D2 local D3 = D.D3 local D4 = D.D4 local D5 = D.D5 local D6 = D.D6 local D7 = D.D7 local D8 = D.D8 x = 0 y = true
while wait() do wait(1) D1.Part.Transparency = x D1.Part.CanCollide = y D1.Union.Transparency = x D1.Union.CanCollide = y D2.Part.Transparency = x D2.Part.CanCollide = y D2.Union.Transparency = x D2.Union.CanCollide = y D3.Part.Transparency = x D3.Part.CanCollide = y D3.Union.Transparency = x D3.Union.CanCollide = y D4.Part.Transparency = x D4.Part.CanCollide = y D4.Union.Transparency = x D4.Union.CanCollide = y D5.Part.Transparency = x D5.Part.CanCollide = y D5.Union.Transparency = x D5.Union.CanCollide = y D6.Part.Transparency = x D6.Part.CanCollide = y D6.Union.Transparency = x D6.Union.CanCollide = y D7.Part.Transparency = x D7.Part.CanCollide = y D7.Union.Transparency = x D7.Union.CanCollide = y D8.Part.Transparency = x D8.Part.CanCollide = y D8.Union.Transparency = x D8.Union.CanCollide = y if _G.Tc1TrainDoorsShut == true then x = 0 y = true else x = 1 y = false end end |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2016 02:06 AM |
| holy crap look up Generic_For in the wiki |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2016 02:10 AM |
for _,part in next,doors:getChildren() do v.Transparency,v.CanCollide = (var and 0) or 1,var end |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2016 02:11 AM |
| literally just shortened 60% of your code into 3 lines |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2016 03:44 AM |
| If you're copying and pasting a lot of stuff, you're doing it wrong. |
|
|
| Report Abuse |
|
|
Gofven
|
  |
| Joined: 18 Jun 2015 |
| Total Posts: 767 |
|
|
| 19 Sep 2016 10:12 AM |
local D = game.Workspace.Train.Triggers.Doors.D1 _G.Tc1TrainDoorsShut = true
while wait() do if _G.Tc1TrainDoorsShut == true then for _, v in pairs(D) do if v:IsA("BasePart") then v.Transparency = 1 v.CanCollide = false end end end end
-----------------------------
Error logs:
17:11:23.382 - ServerScriptService.TrainDoors:7: bad argument #1 to 'pairs' (table expected, got Object) |
|
|
| Report Abuse |
|
|
Gofven
|
  |
| Joined: 18 Jun 2015 |
| Total Posts: 767 |
|
| |
|
Gofven
|
  |
| Joined: 18 Jun 2015 |
| Total Posts: 767 |
|
|
| 19 Sep 2016 10:23 AM |
| Update: I fixed the issue but something makes all part in the folder(not unions) dissapear? Please tell me WHY it happens (It just dissapeared, i saw it in the editor?) |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2016 12:12 PM |
"if v:IsA("BasePart") then v.Transparency = 1 v.CanCollide = false"
|
|
|
| Report Abuse |
|
|