Hey, I hope this isn’t a hassle it’s a really short script that works based on my testing I was just wondering if someone can look over it?
It uses the DataStore2 module made by “Kampfkarren” (the popular one.) I just need a person(s) to make sure it’s okay sine this is my first time saving dictionaries (I think that’s the name) instead of each value in the combine.
The Script
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ExternalModules = ServerScriptService:WaitForChild("External Modules")
local DataStore2 = require(ExternalModules:WaitForChild("DataStore2"))
local Swords = {
["Classic"] = 1,
["Lightning"] = 0,
["Red Lightning"] = 0
}
local Data = {
["Deaths"] = 0,
["Wins"] = 0,
["Top"] = 0,
["Playtime"] = 0,
["Level"] = 0,
["Experience"] = 0,
}
local function GetSwords(Player)
local Swords = DataStore2("Swords", Player):Get({
["Classic"] = 1,
})
return Swords
end
local function GetSettings(Player)
return DataStore2("Data", Player):Get({
["Deaths"] = 0,
["Wins"] = 0,
["Top"] = 0,
["Playtime"] = 0,
["Level"] = 0,
["Experience"] = 0,
})
end
local function SwordIncrement(ChosenValue, Player)
local FunctionSwords = DataStore2("Swords", Player):Get({
["Classic"] = 1,
})
if (not FunctionSwords[ChosenValue]) then
FunctionSwords[ChosenValue] = 1
else
FunctionSwords[ChosenValue] += 1
end
DataStore2("Swords", Player):Set(FunctionSwords)
end
local function DataChange(ChosenValue, Player)
local FunctionData = DataStore2("Data", Player):Get({
["Deaths"] = 0,
["Wins"] = 0,
["Top"] = 0,
["Playtime"] = 0,
["Level"] = 0,
["Experience"] = 0,
})
if (not FunctionData[ChosenValue]) then
FunctionData[ChosenValue] = 1
else
FunctionData[ChosenValue] += 1
end
DataStore2("Data", Player):Set(FunctionData)
end
DataStore2.Combine("TestData2",
"Time",
"Kills",
"Swords",
"Data"
)
Players.PlayerAdded:Connect(function(Player)
local TimeData = DataStore2("Time", Player)
local KillsData = DataStore2("Kills", Player)
local SwordsData = DataStore2("Swords", Player)
local HiddenData = DataStore2("Data", Player)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
local TimeValue = Instance.new("NumberValue")
TimeValue.Name = "Time"
TimeValue.Value = TimeData:Get(0)
TimeValue.Parent = Leaderstats
TimeData:OnUpdate(function(UpdatedValue)
TimeValue.Value = UpdatedValue
end)
local KillsValue = Instance.new("NumberValue")
KillsValue.Name = "Kills"
KillsValue.Value = KillsData:Get(0)
KillsValue.Parent = Leaderstats
KillsData:OnUpdate(function(UpdatedValue)
KillsValue.Value = UpdatedValue
end)
for i, v in pairs(GetSwords(Player)) do
print(Player.Name.."'s Data ".. "["..i.."]".." = ".. v)
end
print("-")
for i, v in pairs(GetSettings(Player)) do
print(Player.Name.."'s Data ".. "["..i.."]".." = ".. v)
end
Leaderstats.Parent = Player
end)