I have tried multiple different ways to save this data, but it seems not to work. The SaveCreateData seems to work and process, but JobDataApply is not saving for some reason. When a player applies it sends it to the server to process it through httpService, but then tries to save it on the server through a BindableEvent
. Instance of this code:
jobData.Event:Connect(function(arg, name, jobId, player)
local AJF = player:FindFirstChild("AppliedJobsFolder")
local CJF = player:FindFirstChild("CreatedJobsFolder")
if arg == "SaveCreate" then
local JobCreate = Instance.new("StringValue", CJF)
JobCreate.Name = name
JobCreate.Value = jobId
elseif arg == "SaveApply" then
local JobApply = Instance.new("StringValue", AJF)
JobApply.Name = name
JobApply.Value = jobId
end
end)
Both of the creating instances work, and I can see that they have been created in studio. I also tried the switch over to serverside, and it was still present.
I then try to save the data by saving everything in the folder, but the applyData does not want to save. I have tried to make it work, but I don’t know why it won’t work. It would make sense if both of them didn’t, but only the applyData doesn’t work, even the print data on the event PlayerRemoving
it prints out the data. Instance of this code:
local ds = game:GetService("DataStoreService")
local SaveDataCreate = ds:GetDataStore("JobDataCreate")
local JobDataApply = ds:GetDataStore("JobSaveApply")
game.Players.PlayerAdded:Connect(function(player)
local playerkey = "id_" .. player.UserId
local AJF = Instance.new("Folder", player)
AJF.Name = "AppliedJobsFolder"
local CJF = Instance.new("Folder", player)
CJF.Name = "CreatedJobsFolder"
local data1 = SaveDataCreate:GetAsync(playerkey) or {}
local data2 = JobDataApply:GetAsync(playerkey) or {}
print("Data1:", data1)
print("Data2:", data2)
for _, obj in pairs(data1) do
local stringVal = Instance.new("StringValue", CJF)
stringVal.Name = obj[1]
stringVal.Value = obj[2]
end
for _, obj in pairs(data2) do
local stringVal2 = Instance.new("StringValue", AJF)
stringVal2.Name = obj[1]
stringVal2.Value = obj[2]
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local AJF = player:FindFirstChild("AppliedJobsFolder")
local CJF = player:FindFirstChild("CreatedJobsFolder")
local playerkey = "id_" .. player.UserId
local data1 = {}
local data2 = {}
for _, v in pairs(AJF:GetChildren()) do
table.insert(data1, {v.Name, v.Value})
end
for _, x in pairs(CJF:GetChildren()) do
table.insert(data2, {x.Name, x.Value})
end
print("Saving Data1:", data1)
print("Saving Data2:", data2)
JobDataApply:SetAsync(playerkey, data1)
SaveDataCreate:SetAsync(playerkey, data2)
end)
If you have any idea of how to fix this please let me know!
Edit:
There is an issue with both.