|
| 03 Aug 2014 08:44 PM |
alreadyDed = {}
function onHead(hit) if hit:IsA("BasePart") and hit.Name == "Head" then if hit.Parent.Name ~= alreadyDed then hit.Parent.Name[alreadyDed] = true hit:Destroy() end end end
script.Parent.Touched:connect(onHead)
This is obviously wrong since it looks horrible. Help me fix this. I'm trying to add the player's name into the table once they die once from it. Then if they get hit again by the same thing they won't die. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 03 Aug 2014 08:51 PM |
Using table.insert
table.insert(YourTable, Value)
-OR-
YourTable:insert(Value)
It will insert the value at the next available numerical index. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 03 Aug 2014 08:54 PM |
Incorrect @({}):insert()...
I dunno why exactly but table classes cannot use functions from the table class. |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2014 08:54 PM |
| I'm not inserting a value tho. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 03 Aug 2014 08:55 PM |
| Oh, whoops, I guess so. I know you can do that for string functions so I assumed it would be the same. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 03 Aug 2014 08:55 PM |
-- Pay attention to what I did.
alreadyDed = {}
function onHead(hit) if hit:IsA("BasePart") and hit.Name == "Head" then if not alreadyDed[hit.Parent.Name] then alreadyDed[hit.Parent.Name] = true hit:Destroy() end end end |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2014 08:59 PM |
| Simple enough. I'll just rearrange things and it'll make it work the way I planned. |
|
|
| Report Abuse |
|
|