Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to access data from a table?

Asked by 5 years ago

For reasons to not exceed the 50kb/s remote event/function data transfer, I made tables used a coding system for guns. For example, instead of having:

["AK47"] = {Damage = 40, ReloadTime = 3}

I made it:

[1] = {GunName = "AK47", Damage = 40, ReloadTime = 3}

But how my gun scripts work is that it uses the tool name to search for the stats within the table so I can easily just put:

gunDamage = gunModule[toolName["Damage"]]

But since I used a coding system, I am forced to name said tool to "1" instead of "AK47". I would rather not for an in pairs function to cycle through the gun codes and see which gunCode[GunName] matches the tool name and then breaks the loop signifying it has found it. This may be a lil confusing but I hope someone could help.

3
Honestly the way you had it first is fine, it'd even be less data. RubenKan 3615 — 5y
1
^ User#21908 42 — 5y
0
I see thank you! Marmalados 193 — 5y

Answer this question