Boksunni1
|
  |
| Joined: 13 May 2009 |
| Total Posts: 485 |
|
|
| 02 Nov 2013 12:02 AM |
| I have a scuba suit brick that welds portions of a scuba suit onto the player. Each portion is a Model named Leg1, Arm1, Chest, etc. I've tried to edit the hat remover script in the hat remover brick, but to no avail. Any help guys? |
|
|
| Report Abuse |
|
|
Boksunni1
|
  |
| Joined: 13 May 2009 |
| Total Posts: 485 |
|
|
| 02 Nov 2013 12:07 AM |
This is the script for hat removal is it makes it any easier.
function onTouched(hit) local d = hit.Parent:GetChildren() for i=1, #d do if (d[i].className == "Hat") then d[i]:remove() end end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2013 12:13 AM |
| Just check the name of d[i] if it matches a table of items you want to remove then Destroy it. using :Destroy() never use :remove() it is deprecated and'll lag your game up as it just reparents it to nil. |
|
|
| Report Abuse |
|
|
Boksunni1
|
  |
| Joined: 13 May 2009 |
| Total Posts: 485 |
|
|
| 02 Nov 2013 12:21 AM |
What does it technically mean when i=1? Sorry, I'm really bad at the scripting business. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2013 12:29 AM |
for i = 1,5 do print(i) end >1 >2 >3 >4 >5 |
|
|
| Report Abuse |
|
|
Boksunni1
|
  |
| Joined: 13 May 2009 |
| Total Posts: 485 |
|
|
| 02 Nov 2013 12:34 AM |
I guess a better question is what is "i"? I've tried searching on lua learning websites and I can't seem to see it at all, ( Since I don't know its practical uses)
I'm very sorry guys for those who are annoyed at me. I just never had the time to read up all this stuff :\ |
|
|
| Report Abuse |
|
|
| |
|
Boksunni1
|
  |
| Joined: 13 May 2009 |
| Total Posts: 485 |
|
|
| 02 Nov 2013 12:38 AM |
| so when it was set to 1, what exactly was it defining? I didn't understand what "1" had to do with finding the hat. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2013 12:43 AM |
| d is a table full of whatever's children. To access what is in this table we need the number of its placement doing for i = 1, #d starts i at one and goes up one by one till it is done with whatever number #d the operator is. So we put d then brackets and finally i to represent the location of the data that we wish to access. |
|
|
| Report Abuse |
|
|
Boksunni1
|
  |
| Joined: 13 May 2009 |
| Total Posts: 485 |
|
|
| 02 Nov 2013 12:55 AM |
| Oh I see... Thanks for clarifying. I'll tinker with this script and see and I can do lol. Even with years of playing, I never got really get into scripting. |
|
|
| Report Abuse |
|
|