Hi,
I have a problem with my DataStore. The DataStore saves the values "money" and “bank”, but not the other values. All values except “Money” and “Bank” are StringValues. There are no error messages in the output
Can you help me with my problem?
My ServerScript:
local DataSoreService = game:GetService("DataStoreService")
local PersoStore = DataSoreService:GetDataStore("PersoStore")
local function onPlayerJoin(plr)
local stats2 = Instance.new("IntValue",plr)
stats2.Name = "Values"
local Briefe = Instance.new("NumberValue",stats2)
Briefe.Name = "Briefe"
local Bank = Instance.new("IntValue",stats2)
Bank.Name = "Bank"
local Geld = Instance.new("IntValue",stats2)
Geld.Name = "Geld"
local Geschlecht = Instance.new("StringValue",stats2)
Geschlecht.Name = "Geschlecht"
local Vorname = Instance.new("StringValue", stats2)
Vorname.Name = "Vorname"
local Nachname = Instance.new("StringValue", stats2)
Nachname.Name = "Nachname"
local Nationalitat = Instance.new("StringValue", stats2)
Nationalitat.Name = "Nationalitat"
Nationalitat.Value = "Deutsch"
local Augenfarbe = Instance.new("StringValue", stats2)
Augenfarbe.Name = "Augenfarbe"
local Groesse = Instance.new("StringValue", stats2)
Groesse.Name = "Groesse"
local Datum = Instance.new("StringValue", stats2)
Datum.Name = "Datum"
local Geburtsort = Instance.new("StringValue", stats2)
Geburtsort.Name = "Geburtsort"
local playerUserId = "Player_"..plr.UserId
local data = PersoStore:GetAsync(playerUserId)
if data then
Bank.Value = data["Bank"]
Geld.Value = data["Geld"]
Geschlecht.Value = data["Geschlecht"]
Vorname.Value = data["Vorname"]
Nachname.Value = data["Nachname"]
Nationalitat.Value = data["Nationalitat"]
Augenfarbe.Value = data["Augenfarbe"]
Groesse.Value = data["Groesse"]
Datum.Value = data["Datum"]
Geburtsort.Value = data["Geburtsort"]
else
Bank.Value = 0
Geld.Value = 5000
end
end
local function create_table(plr)
local player_values = {}
for _, stat in pairs(plr.Values:GetChildren()) do
player_values[stat.Name] = stat.Value
end
return player_values
end
local function onPlayerExit(plr)
local player_values = create_table(plr)
local sucess, err = pcall(function()
local playerUserId = 'Player_'..plr.UserId
PersoStore:SetAsync(playerUserId, player_values)
end)
if not sucess then
warn("Daten konnten nicht gespeichert werden")
end
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
game.Players.PlayerRemoving:Connect(onPlayerExit)
Thanks for helping
Pino