Hello, I am trying to save a “version”. No not a datastore, as a value
I have 2 functions
One edits the module which everything is stored in for each player
One returns the table for the specified player
I am getting the table then printing the value I want, it prints as 1 which is what I want
Then I update the module after
I print the same variable and it prints as 2
How can I fix this?
Code:
local ComboNumber = Combat:getCombo(player)
print(ComboNumber["Current"])
updateCombo(player, true)
print(ComboNumber["Current"])
Nevermind, while writing this I realized its returning the table path, so that’s why it updated when I called the update function. Idk why I didn’t realize that lol
better explanation incase you want to know still:
local ComboNumber = Combat:getCombo(player)
print(ComboNumber["Current"]) -- should print 1
updateCombo(player, true) -- updates the "main" table to 2 instead of 1
print(ComboNumber["Current"]) -- should still print 1
functions used:
function Combat:getCombo(player)
return self["Combos"][player.Name]
end
local function updateCombo(player, state)
if state then
if Combat["Combos"][player.Name]["Current"] >= Combat["Combos"][player.Name]["Max"] then
Combat["Combos"][player.Name]["Current"] = 1
Combat["Combos"][player.Name]["Loops"] += 1
else
Combat["Combos"][player.Name]["Last"] = Combat["Combos"][player.Name]["Current"]
Combat["Combos"][player.Name]["Current"] += 1
end
else
Combat["Combos"][player.Name]["Current"] = 1
Combat["Combos"][player.Name]["Loops"] = 0
Combat["Combos"][player.Name]["Last"] = 0
end
end