My datastore for my game has not been working, and im not sure why, it doesn’t seem to output any errors either.
Here is my code.
local DS = game:GetService("DataStoreService")
local PS = game:GetService("Players")
local RS = game:GetService("RunService")
local Moods = DS:GetDataStore("SCP_INC_PLR_MOODS")
local WebHooks = require(game.ReplicatedStorage.Modules.Webhooks)
PS.PlayerAdded:Connect(function(pl)
local MOODfolder = Instance.new("Folder")
MOODfolder.Name = "MoodData"
MOODfolder.Parent = pl
local godVal = Instance.new("BoolValue")
godVal.Name = "God"
godVal.Parent = MOODfolder
local thirstVal = Instance.new("NumberValue")
thirstVal.Name = "Thirst"
thirstVal.Parent = MOODfolder
local hungerVal = Instance.new("NumberValue")
hungerVal.Name = "Hunger"
hungerVal.Parent = MOODfolder
local dirtinessVal = Instance.new("NumberValue")
dirtinessVal.Name = "Dirtiness"
dirtinessVal.Parent = MOODfolder
local fatigueVal = Instance.new("NumberValue")
fatigueVal.Name = "Fatigue"
fatigueVal.Parent = MOODfolder
local success_MOOD_Thirst, Thirst_Data = pcall(function()
Moods:GetAsync(pl.UserId.."-SCP_INC_MOOD_THIRST")
end)
local success_MOOD_Hunger, Hunger_Data = pcall(function()
Moods:GetAsync(pl.UserId.."-SCP_INC_MOOD_HUNGER")
end)
local success_MOOD_Dirtiness, Dirtiness_Data = pcall(function()
Moods:GetAsync(pl.UserId.."-SCP_INC_MOOD_DIRTINESS")
end)
local Success_MOOD_Fatigue, FatigueData = pcall(function()
Moods:GetAsync(pl.UserId.."SCP_INC_MOOD_FATIGUE")
end)
if success_MOOD_Thirst then
thirstVal.Value = Thirst_Data
else
thirstVal.Value = 0
end
if success_MOOD_Hunger then
hungerVal.Value = Hunger_Data
else
hungerVal.Value = 0
end
if success_MOOD_Dirtiness then
dirtinessVal.Value = Dirtiness_Data
else
dirtinessVal = 0
end
if Success_MOOD_Fatigue then
fatigueVal.Value = FatigueData
else
fatigueVal.Value = 0
end
end)
PS.PlayerRemoving:Connect(function(pl)
local MOODfolder = pl:WaitForChild("MoodData")
local ThirstVal = MOODfolder:WaitForChild("Thirst")
local HungerVal = MOODfolder:WaitForChild("Hunger")
local DirtinessVal = MOODfolder:WaitForChild("Dirtiness")
local FatigueVal = MOODfolder:WaitForChild("Fatigue")
-- // Setting in Data
local ThirstSuccess, ErrorThirst = pcall(function()
Moods:SetAsync(pl.UserId.."-SCP_INC_MOOD_THIRST",ThirstVal.Value)
end)
local HungerSuccess, ErrorHunger = pcall(function()
Moods:SetAsync(pl.UserId.."-SCP_INC_MOOD_HUNGER",HungerVal.Value)
end)
local DirtinessSuccess, ErrorDirtiness = pcall(function()
Moods:SetAsync(pl.UserId.."-SCP_INC_MOOD_DIRTINESS")
end)
local FatigueSuccess, ErrorFatigue = pcall(function()
Moods:SetAsync(pl.UserId.."SCP_INC_MOOD_FATIGUE",FatigueVal.Value)
end)
-- // Communicating with the console for any possible save errors, then sending them over to the discord
if not ThirstSuccess and not RS:IsStudio() then
WebHooks.SendEmbedFeild2(WebHooks.Hooks.SaveFailLogs.Token,"**Save Error**","Possible fail in saving a user's data.",tonumber(0xf30000),"Username","Userid",pl.Name,pl.UserId)
end
if not HungerSuccess and not RS:IsStudio() then
WebHooks.SendEmbedFeild2(WebHooks.Hooks.SaveFailLogs.Token,"**Save Error**","Possible fail in saving a user's data.",tonumber(0xf30000),"Username","Userid",pl.Name,pl.UserId)
end
if not DirtinessSuccess and not RS:IsStudio() then
WebHooks.SendEmbedFeild2(WebHooks.Hooks.SaveFailLogs.Token,"**Save Error**","Possible fail in saving a user's data.",tonumber(0xf30000),"Username","Userid",pl.Name,pl.UserId)
end
if not FatigueSuccess and not RS:IsStudio() then
WebHooks.SendEmbedFeild2(WebHooks.Hooks.SaveFailLogs.Token,"**Save Error**","Possible fail in saving a user's data.",tonumber(0xf30000),"Username","Userid",pl.Name,pl.UserId)
end
end)