tempodoa
|
  |
| Joined: 06 Aug 2012 |
| Total Posts: 251 |
|
|
| 06 Nov 2014 08:33 AM |
Hey, while developing something, I was stuck, tbh I'm really not that great of a scripter. So I was trying to make a script that executes a function which makes a model (Which like 6 Bricks in it) disappear (Go transparency 1 and cancollide false) on click of the click detecor. So this is the script I have so far: function onClicked() local m = script.Parent.Parent.traps:GetChildren() for i = 1, #m do wait(1.5) m.Transparency = .5 wait(1) m.Transparency = 1 m.CanCollide = false wait(6) m.CanCollide = true m.Transparency = 0 end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
IF you could help me I would be grateful :) As mentioned I am really not a very good scripter so there are probably lots of errors |
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 08:35 AM |
function onClicked() local m = script.Parent.Parent.traps:GetChildren() for i = 1, #m do wait(1.5) m[i].Transparency = .5 wait(1) m[i].Transparency = 1 m[i].CanCollide = false wait(6) m[i].CanCollide = true m[i].Transparency = 0 end end script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
tempodoa
|
  |
| Joined: 06 Aug 2012 |
| Total Posts: 251 |
|
|
| 06 Nov 2014 08:42 AM |
| Thanks for the help, but one problem still is, it removes onebrick, puts it back, removes next brick, puts it back etc. Id like it to have it take remove one at a time till all are gone and then make the walkable/visible again. |
|
|
| Report Abuse |
|
|
tempodoa
|
  |
| Joined: 06 Aug 2012 |
| Total Posts: 251 |
|
| |
|
|
| 06 Nov 2014 12:37 PM |
It dosent remove it, it makes it invincible. At least it shouldn't remove it, as there's nothing in the script above that says to remove a part. If it IS removing a part, you have a higher chance of a different script doing so then the one above. |
|
|
| Report Abuse |
|
|
tempodoa
|
  |
| Joined: 06 Aug 2012 |
| Total Posts: 251 |
|
|
| 06 Nov 2014 12:45 PM |
| ^I meant making it invisible and and making it noncancollide causing you to be able to walk through the brick. |
|
|
| Report Abuse |
|
|
Sinecure
|
  |
| Joined: 25 Nov 2010 |
| Total Posts: 871 |
|
|
| 06 Nov 2014 12:54 PM |
function onClicked() local m = script.Parent.Parent.traps:GetChildren()
for i = 1, #m do wait(1.5) m.Transparency = .5 wait(1) m.Transparency = 1 m.CanCollide = false wait(6) m.CanCollide = true m.Transparency = 0 end
end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Conceptually "for i = 1, #m do" is doing "for each part in the model"
so for a model with parts Part1, Part2, and Part3, it's doing...
wait for 1.5 seconds set Part1's transp. to .5 wait for 1 second set Part1's transp to 1 make Part1 nonsolid wait 6 seconds make Part1 solid make Part1 visible
next,
wait for 1.5 seconds set Part2's transp to .5 wait for 1 second set Part1's transp to 1 etc...
This is why you're having a problem. You'll need to do something more like this:
wait 1 second for all parts in the model, set transparency to .5 wait 1.5 seconds for all parts in the model, set transparency to 1 and make nonsolid etc... |
|
|
| Report Abuse |
|
|
tempodoa
|
  |
| Joined: 06 Aug 2012 |
| Total Posts: 251 |
|
|
| 06 Nov 2014 01:28 PM |
| How can I change all parts in the model at once(in transparency and cancollide)? |
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 02:12 PM |
function onClick() local m = script.Parent.Parent.traps:GetChildren() wait(1.5) for I,v in pairs(m) do v.Transparency = .5 end wait(1) for I,v in pairs(m) do v.Transparency = 1 v.CanCollide = false end wait(6) for I,v in pairs(m) do v.CanCollide= true v.Transparency = 0 end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|