Datastore2 how to set default values for 200 combined datastores

I know it’s obvious, but I just don’t know.
What would be an easy way to set the default values for all of these 200 combined datastores to 0?

DataStore2.Combine("MasterSpaceChickenDataStore452", "Sword0", "Sword1", "Sword2", "Sword3", "Sword4", "Sword5", "Sword6", "Sword7", "Sword8", "Sword9", "Sword10", "Sword11", "Sword12", "Sword13", "Sword14", "Sword15", "Sword16", "Sword17", "Sword18", "Sword19", "Sword20", "Sword21", "Sword22", "Sword23", "Sword24", "Sword25", "Sword26", "Sword27", "Sword28", "Sword29", "Sword30", "Sword31", "Sword32", "Sword33", "Sword34", "Sword35", "Sword36", "Sword37", "Sword38", "Sword39", "Sword40", "Sword41", "Sword42", "Sword43", "Sword44", "Sword45", "Sword46", "Sword47", "Sword48", "Sword49", "Sword50", "Sword51", "Sword52", "Sword53", "Sword54", "Sword55", "Sword56", "Sword57", "Sword58", "Sword59", "Sword60", "Sword61", "Sword62", "Sword63", "Sword64", "Sword65", "Sword66", "Sword67", "Sword68", "Sword69", "Sword70", "Sword71", "Sword72", "Sword73", "Sword74", "Sword75", "Sword76", "Sword77", "Sword78", "Sword79", "Sword80", "Sword81", "Sword82", "Sword83", "Sword84", "Sword85", "Sword86", "Sword87", "Sword88", "Sword89", "Sword90", "Sword91", "Sword92", "Sword93", "Sword94", "Sword95", "Sword96", "Sword97", "Sword98", "Sword99", "Sword100", "Sword101", "Sword102", "Sword103", "Sword104", "Sword105", "Sword106", "Sword107", "Sword108", "Sword109", "Sword110", "Sword111", "Sword112", "Sword113", "Sword114", "Sword115", "Sword116", "Sword117", "Sword118", "Sword119", "Sword120", "Sword121", "Sword122", "Sword123", "Sword124", "Sword125", "Sword126", "Sword127", "Sword128", "Sword129", "Sword130", "Sword131", "Sword132", "Sword133", "Sword134", "Sword135", "Sword136", "Sword137", "Sword138", "Sword139", "Sword140", "Sword141", "Sword142", "Sword143", "Sword144", "Sword145", "Sword146", "Sword147", "Sword148", "Sword149", "Sword150", "Sword151", "Sword152", "Sword153", "Sword154", "Sword155", "Sword156", "Sword157", "Sword158", "Sword159", "Sword160", "Sword161", "Sword162", "Sword163", "Sword164", "Sword165", "Sword166", "Sword167", "Sword168", "Sword169", "Sword170", "Sword171", "Sword172", "Sword173", "Sword174", "Sword175", "Sword176", "Sword177", "Sword178", "Sword179", "Sword180", "Sword181", "Sword182", "Sword183", "Sword184", "Sword185", "Sword186", "Sword187", "Sword188", "Sword189", "Sword190", "Sword191", "Sword192", "Sword193", "Sword194", "Sword195", "Sword196", "Sword197", "Sword198", "Sword199", "Sword200")`
1 Like

This is actually part of a bigger task I am trying to setup. I want to setup a datastore for 200 swords. Then to read if the player owns any of the swords. 0 -no own and 1 -owns sword. Each sword has a different bonus. The bonus will be cumulative of all swords owned. That is the plan. BTW I also have 65 Avatars, but if we can fix it for the swords I can fix it for the avatars.

`local DataStore2 = require(1936396537)
local Players = game:GetService(“Players”)
local player = Players.LocalPlayer
wait(3)
–SwordBonusTables

SwordBonusTableBlue = {[0]=“0”,[1]=“20”,[2]=“30”,[3]=“40”,[4]=“50”,[5]=“60”,[6]=“7”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“0”,[66]=“0”,[67]=“0”,[68]=“0”,[69]=“0”,[70]=“0”,[71]=“0”,[72]=“0”,[73]=“0”,[74]=“0”,[75]=“0”,[76]=“0”,[77]=“0”,[78]=“0”,[79]=“0”,[80]=“0”,[81]=“0”,[82]=“0”,[83]=“0”,[84]=“0”,[85]=“0”,[86]=“0”,[87]=“0”,[88]=“0”,[89]=“0”,[90]=“0”,[91]=“0”,[92]=“0”,[93]=“0”,[94]=“0”,[95]=“0”,[96]=“0”,[97]=“0”,[98]=“0”,[99]=“0”,[100]=“100000”,[101]=“0”,[102]=“0”,[103]=“0”,[104]=“0”,[105]=“0”,[106]=“0”,[107]=“0”,[108]=“0”,[109]=“0”,[110]=“0”,[111]=“0”,[112]=“0”,[113]=“0”,[114]=“0”,[115]=“0”,[116]=“0”,[117]=“0”,[118]=“0”,[119]=“0”,[120]=“0”,[121]=“0”,[122]=“0”,[123]=“0”,[124]=“0”,[125]=“0”,[126]=“0”,[127]=“0”,[128]=“0”,[129]=“0”,[130]=“0”,[131]=“0”,[132]=“0”,[133]=“0”,[134]=“0”,[135]=“0”,[136]=“0”,[137]=“0”,[138]=“0”,[139]=“0”,[140]=“0”,[141]=“0”,[142]=“0”,[143]=“0”,[144]=“0”,[145]=“0”,[146]=“0”,[147]=“0”,[148]=“0”,[149]=“0”,[150]=“0”,[151]=“0”,[152]=“0”,[153]=“0”,[154]=“0”,[155]=“0”,[156]=“0”,[157]=“0”,[158]=“0”,[159]=“0”,[160]=“0”,[161]=“0”,[162]=“0”,[163]=“0”,[164]=“0”,[165]=“0”,[166]=“0”,[167]=“0”,[168]=“0”,[169]=“0”,[170]=“0”,[171]=“0”,[172]=“0”,[173]=“0”,[174]=“0”,[175]=“0”,[176]=“0”,[177]=“0”,[178]=“0”,[179]=“0”,[180]=“0”,[181]=“0”,[182]=“0”,[183]=“0”,[184]=“0”,[185]=“0”,[186]=“0”,[187]=“0”,[188]=“0”,[189]=“0”,[190]=“0”,[191]=“0”,[192]=“0”,[193]=“0”,[194]=“0”,[195]=“0”,[196]=“0”,[197]=“100”,[198]=“100”,[199]=“100”,[200]=“1000”,}

SwordBonusTableGreen = {[0]=“0”,[1]=“100”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“0”,[66]=“0”,[67]=“0”,[68]=“0”,[69]=“0”,[70]=“0”,[71]=“0”,[72]=“0”,[73]=“0”,[74]=“0”,[75]=“0”,[76]=“0”,[77]=“0”,[78]=“0”,[79]=“0”,[80]=“0”,[81]=“0”,[82]=“0”,[83]=“0”,[84]=“0”,[85]=“0”,[86]=“0”,[87]=“0”,[88]=“0”,[89]=“0”,[90]=“0”,[91]=“0”,[92]=“0”,[93]=“0”,[94]=“0”,[95]=“0”,[96]=“0”,[97]=“0”,[98]=“0”,[99]=“0”,[100]=“0”,[101]=“0”,[102]=“0”,[103]=“0”,[104]=“0”,[105]=“0”,[106]=“0”,[107]=“0”,[108]=“0”,[109]=“0”,[110]=“0”,[111]=“0”,[112]=“0”,[113]=“0”,[114]=“0”,[115]=“0”,[116]=“0”,[117]=“0”,[118]=“0”,[119]=“0”,[120]=“0”,[121]=“0”,[122]=“0”,[123]=“0”,[124]=“0”,[125]=“0”,[126]=“0”,[127]=“0”,[128]=“0”,[129]=“0”,[130]=“0”,[131]=“0”,[132]=“0”,[133]=“0”,[134]=“0”,[135]=“0”,[136]=“0”,[137]=“0”,[138]=“0”,[139]=“0”,[140]=“0”,[141]=“0”,[142]=“0”,[143]=“0”,[144]=“0”,[145]=“0”,[146]=“0”,[147]=“0”,[148]=“0”,[149]=“0”,[150]=“0”,[151]=“0”,[152]=“0”,[153]=“0”,[154]=“0”,[155]=“0”,[156]=“0”,[157]=“0”,[158]=“0”,[159]=“0”,[160]=“0”,[161]=“0”,[162]=“0”,[163]=“0”,[164]=“0”,[165]=“0”,[166]=“0”,[167]=“0”,[168]=“0”,[169]=“0”,[170]=“0”,[171]=“0”,[172]=“0”,[173]=“0”,[174]=“0”,[175]=“0”,[176]=“0”,[177]=“0”,[178]=“0”,[179]=“0”,[180]=“0”,[181]=“0”,[182]=“0”,[183]=“0”,[184]=“0”,[185]=“0”,[186]=“0”,[187]=“0”,[188]=“0”,[189]=“0”,[190]=“0”,[191]=“0”,[192]=“0”,[193]=“0”,[194]=“0”,[195]=“0”,[196]=“0”,[197]=“0”,[198]=“0”,[199]=“0”,[200]=“100”,}

SwordBonusTableYellow = {[0]=“0”,[1]=“200”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“0”,[66]=“0”,[67]=“0”,[68]=“0”,[69]=“0”,[70]=“0”,[71]=“0”,[72]=“0”,[73]=“0”,[74]=“0”,[75]=“0”,[76]=“0”,[77]=“0”,[78]=“0”,[79]=“0”,[80]=“0”,[81]=“0”,[82]=“0”,[83]=“0”,[84]=“0”,[85]=“0”,[86]=“0”,[87]=“0”,[88]=“0”,[89]=“0”,[90]=“0”,[91]=“0”,[92]=“0”,[93]=“0”,[94]=“0”,[95]=“0”,[96]=“0”,[97]=“0”,[98]=“0”,[99]=“0”,[100]=“0”,[101]=“0”,[102]=“0”,[103]=“0”,[104]=“0”,[105]=“0”,[106]=“0”,[107]=“0”,[108]=“0”,[109]=“0”,[110]=“0”,[111]=“0”,[112]=“0”,[113]=“0”,[114]=“0”,[115]=“0”,[116]=“0”,[117]=“0”,[118]=“0”,[119]=“0”,[120]=“0”,[121]=“0”,[122]=“0”,[123]=“0”,[124]=“0”,[125]=“0”,[126]=“0”,[127]=“0”,[128]=“0”,[129]=“0”,[130]=“0”,[131]=“0”,[132]=“0”,[133]=“0”,[134]=“0”,[135]=“0”,[136]=“0”,[137]=“0”,[138]=“0”,[139]=“0”,[140]=“0”,[141]=“0”,[142]=“0”,[143]=“0”,[144]=“0”,[145]=“0”,[146]=“0”,[147]=“0”,[148]=“0”,[149]=“0”,[150]=“0”,[151]=“0”,[152]=“0”,[153]=“0”,[154]=“0”,[155]=“0”,[156]=“0”,[157]=“0”,[158]=“0”,[159]=“0”,[160]=“0”,[161]=“0”,[162]=“0”,[163]=“0”,[164]=“0”,[165]=“0”,[166]=“0”,[167]=“0”,[168]=“0”,[169]=“0”,[170]=“0”,[171]=“0”,[172]=“0”,[173]=“0”,[174]=“0”,[175]=“0”,[176]=“0”,[177]=“0”,[178]=“0”,[179]=“0”,[180]=“0”,[181]=“0”,[182]=“0”,[183]=“0”,[184]=“0”,[185]=“0”,[186]=“0”,[187]=“0”,[188]=“0”,[189]=“0”,[190]=“0”,[191]=“0”,[192]=“0”,[193]=“0”,[194]=“0”,[195]=“0”,[196]=“0”,[197]=“0”,[198]=“0”,[199]=“0”,[200]=“200”,}

SwordBonusTableRed = {[0]=“0”,[1]=“300”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“0”,[66]=“0”,[67]=“0”,[68]=“0”,[69]=“0”,[70]=“0”,[71]=“0”,[72]=“0”,[73]=“0”,[74]=“0”,[75]=“0”,[76]=“0”,[77]=“0”,[78]=“0”,[79]=“0”,[80]=“0”,[81]=“0”,[82]=“0”,[83]=“0”,[84]=“0”,[85]=“0”,[86]=“0”,[87]=“0”,[88]=“0”,[89]=“0”,[90]=“0”,[91]=“0”,[92]=“0”,[93]=“0”,[94]=“0”,[95]=“0”,[96]=“0”,[97]=“0”,[98]=“0”,[99]=“0”,[100]=“0”,[101]=“0”,[102]=“0”,[103]=“0”,[104]=“0”,[105]=“0”,[106]=“0”,[107]=“0”,[108]=“0”,[109]=“0”,[110]=“0”,[111]=“0”,[112]=“0”,[113]=“0”,[114]=“0”,[115]=“0”,[116]=“0”,[117]=“0”,[118]=“0”,[119]=“0”,[120]=“0”,[121]=“0”,[122]=“0”,[123]=“0”,[124]=“0”,[125]=“0”,[126]=“0”,[127]=“0”,[128]=“0”,[129]=“0”,[130]=“0”,[131]=“0”,[132]=“0”,[133]=“0”,[134]=“0”,[135]=“0”,[136]=“0”,[137]=“0”,[138]=“0”,[139]=“0”,[140]=“0”,[141]=“0”,[142]=“0”,[143]=“0”,[144]=“0”,[145]=“0”,[146]=“0”,[147]=“0”,[148]=“0”,[149]=“0”,[150]=“0”,[151]=“0”,[152]=“0”,[153]=“0”,[154]=“0”,[155]=“0”,[156]=“0”,[157]=“0”,[158]=“0”,[159]=“0”,[160]=“0”,[161]=“0”,[162]=“0”,[163]=“0”,[164]=“0”,[165]=“0”,[166]=“0”,[167]=“0”,[168]=“0”,[169]=“0”,[170]=“0”,[171]=“0”,[172]=“0”,[173]=“0”,[174]=“0”,[175]=“0”,[176]=“0”,[177]=“0”,[178]=“0”,[179]=“0”,[180]=“0”,[181]=“0”,[182]=“0”,[183]=“0”,[184]=“0”,[185]=“0”,[186]=“0”,[187]=“0”,[188]=“0”,[189]=“0”,[190]=“0”,[191]=“0”,[192]=“0”,[193]=“0”,[194]=“0”,[195]=“0”,[196]=“0”,[197]=“0”,[198]=“0”,[199]=“0”,[200]=“300”,}

SwordBonusTableGold = {[0]=“0”,[1]=“400”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“0”,[66]=“0”,[67]=“0”,[68]=“0”,[69]=“0”,[70]=“0”,[71]=“0”,[72]=“0”,[73]=“0”,[74]=“0”,[75]=“0”,[76]=“0”,[77]=“0”,[78]=“0”,[79]=“0”,[80]=“0”,[81]=“0”,[82]=“0”,[83]=“0”,[84]=“0”,[85]=“0”,[86]=“0”,[87]=“0”,[88]=“0”,[89]=“0”,[90]=“0”,[91]=“0”,[92]=“0”,[93]=“0”,[94]=“0”,[95]=“0”,[96]=“0”,[97]=“0”,[98]=“0”,[99]=“0”,[100]=“0”,[101]=“0”,[102]=“0”,[103]=“0”,[104]=“0”,[105]=“0”,[106]=“0”,[107]=“0”,[108]=“0”,[109]=“0”,[110]=“0”,[111]=“0”,[112]=“0”,[113]=“0”,[114]=“0”,[115]=“0”,[116]=“0”,[117]=“0”,[118]=“0”,[119]=“0”,[120]=“0”,[121]=“0”,[122]=“0”,[123]=“0”,[124]=“0”,[125]=“0”,[126]=“0”,[127]=“0”,[128]=“0”,[129]=“0”,[130]=“0”,[131]=“0”,[132]=“0”,[133]=“0”,[134]=“0”,[135]=“0”,[136]=“0”,[137]=“0”,[138]=“0”,[139]=“0”,[140]=“0”,[141]=“0”,[142]=“0”,[143]=“0”,[144]=“0”,[145]=“0”,[146]=“0”,[147]=“0”,[148]=“0”,[149]=“0”,[150]=“0”,[151]=“0”,[152]=“0”,[153]=“0”,[154]=“0”,[155]=“0”,[156]=“0”,[157]=“0”,[158]=“0”,[159]=“0”,[160]=“0”,[161]=“0”,[162]=“0”,[163]=“0”,[164]=“0”,[165]=“0”,[166]=“0”,[167]=“0”,[168]=“0”,[169]=“0”,[170]=“0”,[171]=“0”,[172]=“0”,[173]=“0”,[174]=“0”,[175]=“0”,[176]=“0”,[177]=“0”,[178]=“0”,[179]=“0”,[180]=“0”,[181]=“0”,[182]=“0”,[183]=“0”,[184]=“0”,[185]=“0”,[186]=“0”,[187]=“0”,[188]=“0”,[189]=“0”,[190]=“0”,[191]=“0”,[192]=“0”,[193]=“0”,[194]=“0”,[195]=“0”,[196]=“0”,[197]=“0”,[198]=“0”,[199]=“0”,[200]=“400”,}

–AvatarBonusTable

AvatarBonusTableBlue = {[0]=“0”,[1]=“1000”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“1000”,}

AvatarBonusTableGreen = {[0]=“0”,[1]=“2000”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“2000”,}

AvatarBonusTableYellow = {[0]=“0”,[1]=“3000”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“3000”,}

AvatarBonusTableRed = {[0]=“0”,[1]=“4000”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“4000”,}

AvatarBonusTableGold = {[0]=“0”,[1]=“5000”,[2]=“0”,[3]=“0”,[4]=“0”,[5]=“0”,[6]=“0”,[7]=“0”,[8]=“0”,[9]=“0”,[10]=“0”,[11]=“0”,[12]=“0”,[13]=“0”,[14]=“0”,[15]=“0”,[16]=“0”,[17]=“0”,[18]=“0”,[19]=“0”,[20]=“0”,[21]=“0”,[22]=“0”,[23]=“0”,[24]=“0”,[25]=“0”,[26]=“0”,[27]=“0”,[28]=“0”,[29]=“0”,[30]=“0”,[31]=“0”,[32]=“0”,[33]=“0”,[34]=“0”,[35]=“0”,[36]=“0”,[37]=“0”,[38]=“0”,[39]=“0”,[40]=“0”,[41]=“0”,[42]=“0”,[43]=“0”,[44]=“0”,[45]=“0”,[46]=“0”,[47]=“0”,[48]=“0”,[49]=“0”,[50]=“0”,[51]=“0”,[52]=“0”,[53]=“0”,[54]=“0”,[55]=“0”,[56]=“0”,[57]=“0”,[58]=“0”,[59]=“0”,[60]=“0”,[61]=“0”,[62]=“0”,[63]=“0”,[64]=“0”,[65]=“5000”,}

–Calculate cumulative Bonuses
–As the player wins swords, their sword collection increases and any swords owned will affect a cumulative bonus. Not just the sword equipped.

local TotalBonusBlue = 0
local TotalBonusGreen = 0
local TotalBonusYellow = 0
local TotalBonusRed = 0
local TotalBonusGold = 0

for i = 1,200 do
	local valueBlue
	local valueGreen
	local valueYellow
	local valueRed
	local valueGold
	local swordOwned

	local swordOwned = (DataStore2("Sword"..i, player):Get())
	
		if swordOwned == 1 then
			valueBlue = (SwordBonusTableBlue[i])
			valueGreen = (SwordBonusTableGreen[i])
			valueYellow = (SwordBonusTableYellow[i])
			valueRed = (SwordBonusTableRed[i])
			valueGold = (SwordBonusTableGold[i])
	
			TotalBonusBlue = (TotalBonusBlue + valueBlue)
			TotalBonusGreen = (TotalBonusGreen + valueGreen)
			TotalBonusYellow = (TotalBonusYellow + valueYellow)
			TotalBonusRed = (TotalBonusRed + valueRed)
			TotalBonusGold = (TotalBonusGold + valueGold)
		end

		if i == 200 then
			print("Total Blue Bonus "..TotalBonusBlue)
			print("Total Green Bonus "..TotalBonusGreen)
			print("Total Yellow Bonus "..TotalBonusYellow)
			print("Total Red Bonus "..TotalBonusRed)
			print("Total Gold Bonus "..TotalBonusGold)
		end
end

local AvatarLevel = 65 --This will be set by a get from the datastore.

local TotalBonusBlue = 0
local TotalBonusGreen = 0
local TotalBonusYellow = 0
local TotalBonusRed = 0
local TotalBonusGold = 0

for i = 1,AvatarLevel do
	local valueBlue
	local valueGreen
	local valueYellow
	local valueRed
	local valueGold
	
	valueBlue = (AvatarBonusTableBlue[i])
	valueGreen = (AvatarBonusTableGreen[i])
	valueYellow = (AvatarBonusTableYellow[i])
	valueRed = (AvatarBonusTableRed[i])
	valueGold = (AvatarBonusTableGold[i])
	
	TotalBonusBlue = (TotalBonusBlue + valueBlue)
	TotalBonusGreen = (TotalBonusGreen + valueGreen)
	TotalBonusYellow = (TotalBonusYellow + valueYellow)
	TotalBonusRed = (TotalBonusRed + valueRed)
	TotalBonusGold = (TotalBonusGold + valueGold)


	if i == AvatarLevel then
		print("Total Avatar Blue Bonus "..TotalBonusBlue)
		print("Total Avatar Green Bonus "..TotalBonusGreen)
		print("Total Avatar Yellow Bonus "..TotalBonusYellow)
		print("Total Avatar Red Bonus "..TotalBonusRed)
		print("Total Avatar Gold Bonus "..TotalBonusGold)
	end

end`

My sword ID part of the loop has some syntax problems.

Have you… ever heard of the pairs function by any chance?

for key, value in pairs(array) do
	print(key, value)
end

To be a little more specific, I don’t really understand why you wrote code to initialize all of those values to zero when you could have use a for loop to initialize them.

Apologies if this isn’t related to what you’re trying to fix, but I’m just bewildered looking at all this code. No clue why you would need to write any of that stuff manually.

8 Likes

I apologize for the lack of explanation. I have 200 swords. Each sword will have five possible bonus values. I have not entered in those bonus values yet. Yes that tables have mainly zeros, that will change in the next couple days. That will take a couple days of spread sheet planning.

Think Doomspires with bonuses for destroying different colored towers.

Each sword and avatar will have 5 possible bonus value that will work into a bigger calculation. You get the bonus for all swords purchased/collected and all avatars owned.

Blue Brick Bonus Percentage
Green Brick Bonus Percentage
Yellow Brick Bonus Percentage
Red Brick Bonus Percentage
Gold Bonus Percentage

1 Like

I see, thanks for elaborating.

As far as how I would structure something like this in Lua, I would advise against prefixing all 200 keys with “Sword”, as that’ll consume more memory than necessary.

Instead, you should use a single key in the DataStore that stores an array of the swords that you currently own. Perhaps with a unique id assigned to each sword? I’m not familiar with how DataStore2 works, but hopefully it should be clear how to set a single key/value in your data store.

Also, I would suggest maybe using a linear equation for computing a sword’s bonus instead of storing all 200 values in a spread sheet.

To add on to this, you could store all the bonus data in one table.

example of one value saved:

local data = {Sword = SwordID, BonusRed = BonusRed, BonusBlue = BonusBlue} -- and so on
-- now insert this sword's data into one big array of all your sword datas
local swordsdata = {} -- master table
table.insert(swordsdata, data) -- add our data to the big table

DataStore2:SetAsync(swordsdata) -- we're only saving one big table with all our sword data in it

Now to retrieve all our data, we’ll use the pairs function to index all our values inside of the big table

local swordsdata = DataStore:GetAsync() -- get our data using the module's methods (I dont know them)

for i, sworddata in pairs (swordsdata) do
-- we can index all the values in the swordata from here
local example = sworddata.BonusRed
end

Thanks, I’ll try this. It may take me a while. I’ll do the first 12 and test it out.

1 Like