So I’m working on a battle system and wanted to save move data by bool values (true = has move, false = doesn’t have it) and the following happens within this script,
– Services
local http = game:GetService("HttpService")
local DS = game:GetService("DataStoreService")
local MS = DS:GetDataStore("MoveSave")
-- Stats
local types = require(script.Parent.Types)
local eff = {"Burn","Freeze","Paralyze","Poison"}
-- Types {Fire,Water,Land,Earth,Ice,Wind,Thunder,Dark,Light,Toxic}
-- ["Name"] = {Type,Effect,Damage,Accuracy}
local moves = {
["Burn"] = {types[1],eff[1],0,90},
["Freeze"] = {types[5],eff[2],0,90},
["Paralyze"] = {types[7],eff[3],0,90},
["Poison"] = {types[10],eff[4],0,90}
}
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "Moves"
-- Insert
for i,v in pairs(moves) do
local m = Instance.new("BoolValue",folder)
local s = Instance.new("StringValue",m)
local stats = http:JSONEncode(v) -- testing stuff
print(stats)
m.Name = i
s.Value = stats
s.Name = "MoveStats"
m.Changed:Connect(function()
MS:SetAsync(player.UserId,m.Value)
print("Saved "..m.Name)
end)
end
local Data = MS:GetAsync(player.UserId)
if Data == nil then
print("Nothing to Load")
else
print("Loaded")
end
end)
It print’s Nothing to Load & Loaded if tested EDIT - Also it does give what value was changed in output but doesn’t load the new value properly. Wasn’t sure what I’m doing wrong here. Thanks in advanced
-Notrealac0unt