I am trying to save a table from a module script but instead it’s saving the string value’s of two different string value’s.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local InventoryModule = require(ServerStorage:FindFirstChild("Inventory"))
local EnemiesModule = require(ServerStorage:FindFirstChild("Enemies"))
local StatsModule = require(ServerStorage:FindFirstChild("StatsModule"))
local Events = ReplicatedStorage:FindFirstChild("Events")
local AddDrop = Events:FindFirstChild("AddDrop")
local AddInventory = Events:FindFirstChild("AddInventory")
local DeleteInventory = Events:FindFirstChild("DeleteInventory")
local Equip = Events:FindFirstChild("Equip")
local DataStore2 = require(ServerScriptService.DataStore2)
DataStore2.Combine("Coins")
DataStore2.Combine("Stats")
DataStore2.Combine("Inventory")
DataStore2.Combine("Blade", "Handle")
DataStore2.Combine("Data", "Level", "Exp", "MaxExp","SP")
Players.PlayerAdded:Connect(function(Player)
local CoinsStore = DataStore2("Coins", Player)
local StatsStore = DataStore2("Stats", Player)
local HandleStore = DataStore2("Handle", Player)
local BladeStore = DataStore2("Blade", Player)
local LevelStore = DataStore2("Level", Player)
local ExpStore = DataStore2("Exp", Player)
local MaxExpStore = DataStore2("MaxExp", Player)
local SPStore = DataStore2("SP", Player)
local InventoryStore = DataStore2("Inventory", Player)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "Leaderstats"
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = CoinsStore:Get()
Coins.Parent = Leaderstats
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Value = LevelStore:Get()
Level.Parent = Leaderstats
local Exp = Instance.new("IntValue")
Exp.Name = "Exp"
Exp.Value = ExpStore:Get()
Exp.Parent = Leaderstats
local MaxExp = Instance.new("IntValue")
MaxExp.Name = "MaxExp"
MaxExp.Value = MaxExpStore:Get()
MaxExp.Parent = Leaderstats
local SP = Instance.new("IntValue")
SP.Name = "SP"
SP.Value = SPStore:Get()
SP.Parent = Leaderstats
local Handle = Instance.new("StringValue")
Handle.Name = "Handle"
Handle.Value = HandleStore:Get("Sword Handle")
Handle.Parent = Leaderstats
local Blade = Instance.new("StringValue")
Blade.Name = "Blade"
Blade.Value = BladeStore:Get("Sword Blade")
Blade.Parent = Leaderstats
InventoryModule = InventoryStore:Get()
StatsModule = StatsStore:Get()
print(InventoryModule)
print(StatsModule)
if MaxExpStore:Get() == nil then
MaxExp.Value = 50
end
if SPStore:Get() == nil then
SP.Value = 5
end
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.WalkSpeed = Humanoid.WalkSpeed + (StatsModule.Speed.Value/10)
end)
end)
Players.PlayerRemoving:Connect(function(Player)
local Leaderstats = Player:FindFirstChild("Leaderstats")
local Coins = Leaderstats:FindFirstChild("Coins")
local Level = Leaderstats:FindFirstChild("Level")
local Exp = Leaderstats:FindFirstChild("Exp")
local MaxExp = Leaderstats:FindFirstChild("MaxExp")
local SP = Leaderstats:FindFirstChild("SP")
local Handle = Leaderstats:FindFirstChild("Handle")
local Blade = Leaderstats:FindFirstChild("Blade")
---------------------------------------------------------
local InventoryStore = DataStore2("Inventory", Player)
local StatsStore = DataStore2("Stats", Player)
local CoinsStore = DataStore2("Coins", Player)
local LevelStore = DataStore2("Level", Player)
local ExpStore = DataStore2("Exp", Player)
local MaxExpStore = DataStore2("MaxExp", Player)
local SPStore = DataStore2("SP", Player)
local HandleStore = DataStore2("Handle", Player)
local BladeStore = DataStore2("Blade", Player)
InventoryStore:Set(InventoryModule)
StatsStore:Set(StatsModule)
CoinsStore:Set(Coins.Value)
LevelStore:Set(Level.Value)
ExpStore:Set(Exp.Value)
MaxExpStore:Set(MaxExp.Value)
SPStore:Set(SP.Value)
HandleStore:Set(Handle.Value)
BladeStore:Set(Blade.Value)
end)