generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How to insert stuff in tables?

Previous Thread :: Next Thread 
DualWindforks is not online. DualWindforks
Joined: 17 Oct 2013
Total Posts: 153
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 is not online. 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 is not online. 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
DualWindforks is not online. DualWindforks
Joined: 17 Oct 2013
Total Posts: 153
03 Aug 2014 08:54 PM
I'm not inserting a value tho.
Report Abuse
blockoo is not online. 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 is not online. 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
DualWindforks is not online. DualWindforks
Joined: 17 Oct 2013
Total Posts: 153
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image