It will be more convenient if you create a module script that processes a large number of tables and apply it to the profile service. By the way, why are you trying to save the module script?
If AbilityName, ActivationType, Knockback, Shape, or Speed ​​change, you have no choice but to save it that way. However, if you can change the data with “Punch” or “Smash”, it will be more efficient to change it. If you need to use that profile template, you can create a module as mentioned earlier and reduce repetitive code with the getSlot and saveSlot functions. Alternatively, you can save it in Array format rather than Dictionary format, but this method is not recommended as it contains “None”.
local Template = require(script.Parent.Data.Data.Template)
local DataStore2 = require(script.Parent.Data.ProfileService)
local Manager = require(script.Parent.Data.Manager)
ProfileStore = DataStore2.GetProfileStore("Data", Template)
game:GetService("ReplicatedStorage"):WaitForChild("Remote").OnServerEvent:Connect(function(plr,Place,Value,First,Second,Third,Four,Five)
if Place then
local profile = ProfileStore:LoadProfileAsync("Player_"..plr.UserId)
Place.Value = Value
if First ~= nil and Second == nil and Third == nil and Four == nil and Five == nil then
profile.Data[First] = Value
end
if Second ~= nil and Third == nil and Four == nil and Five == nil then
profile.Data[First][Second] = Value
end
if Third ~= nil and Four == nil and Five == nil then
profile.Data[First][Second][Third] = Value
end
if Four ~= nil and Five == nil then
profile.Data[First][Second][Third][Four] = Value
end
if Five ~= nil then
profile.Data[First][Second][Third][Four][Five] = Value
end
end
end)
local ProfileServiceManager = game.ServerScriptService.ProfileServiceManager
game:GetService("ReplicatedStorage"):WaitForChild("Remote").OnServerEvent:Connect(function(plr,Place,Value,First,Second,Third,Four,Five)
if Place then
local profile = ProfileServiceManager:GetProfile(plr)
Place.Value = Value
if First ~= nil and Second == nil and Third == nil and Four == nil and Five == nil then
profile.Data[First] = Value
ProfileServiceManager:UpdateProfile(plr, First, profile.Data[First])
end
if Second ~= nil and Third == nil and Four == nil and Five == nil then
profile.Data[First][Second] = Value
ProfileServiceManager:UpdateProfile(plr, First, profile.Data[First])
end
if Third ~= nil and Four == nil and Five == nil then
profile.Data[First][Second][Third] = Value
ProfileServiceManager:UpdateProfile(plr, First, profile.Data[First])
end
if Four ~= nil and Five == nil then
profile.Data[First][Second][Third][Four] = Value
ProfileServiceManager:UpdateProfile(plr, First, profile.Data[First])
end
if Five ~= nil then
profile.Data[First][Second][Third][Four][Five] = Value
ProfileServiceManager:UpdateProfile(plr, First, profile.Data[First])
end
ProfileServiceManager:SaveProfile(plr)
end
end)