compy111
|
  |
| Joined: 02 Apr 2009 |
| Total Posts: 583 |
|
|
| 29 Mar 2014 05:29 AM |
I am working on an RPG and it has multiple skills you will have to improve. But as in every game you may have multiple skills but still you need a total level to have an idea of who is how far in the game. In the script that writes all the player's levels into a GUI I used lists and then it used the names of the skills to find them. This makes it easy for me to add more skills later. I just have to add a GUI text, add it to the save data script and add it to the list.
But I have no idea how I could get the numbers together in one formula. I usually use a for function, but this only takes one skill at a time. I could do: combatlevels[1] + combatlevels[2] + combatlevels[3] + combatlevels[4]
But if for example there would be 1000 skills it would take hours to make it, anyone knows how to do it?
My current working script where the part has to be added:
player = script.Parent.Parent.Parent.Parent combatlevels = {"Ranged","Health","Strength","Defense"}
while true do wait() for i = 1 , #combatlevels do stats = player:FindFirstChild("Stats") if stats then level = player.Stats.Combat:FindFirstChild(combatlevels[i]) print(level.Name) GUI = script.Parent:FindFirstChild(combatlevels[i]) GUI.Text = combatlevels[i]..": "..level.Value end end end
Thanks for your help |
|
|
| Report Abuse |
|
|
compy111
|
  |
| Joined: 02 Apr 2009 |
| Total Posts: 583 |
|
|
| 29 Mar 2014 06:08 AM |
| My own replies to others make my post go back to the bottom of the list, so here it goes up again :-) |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2014 07:32 AM |
values = {1, 3, 7, 8, 2} total = 0
for i = 1, #values do total = total + values[i] end |
|
|
| Report Abuse |
|
|