I am trying to save stat values in my datastore, player position, and some others.
When running with all of them I get the error “Unable to cast value to Object.” I think I may be trying to save too many slots of data?
I have tried using all of them individually, such as (AttackValue, scope), and they all went without errors.
Script
local function Datastore(player)
local scope = player.UserId
local Attack = player:WaitForChild("Attack")
local AttackValue = Attack.Value
local Intellect = player:WaitForChild("Intellect")
local IntellectValue = Intellect.Value
local Dexterity = player:WaitForChild("Dexterity")
local DexterityValue = Dexterity.Value
local Defense = player:WaitForChild("Defense")
local DefenseValue = Defense.Value
local Profession = player:WaitForChild("Profession")
local ProfessionValue = Profession.Value
local Loarxion = player:WaitForChild("Loarxion")
local LoarxionValue = Loarxion.Value
local HumanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
local HumanoidRootPartLocation = HumanoidRootPart.Position
local Location = {HumanoidRootPartLocation.X, HumanoidRootPartLocation.Y, HumanoidRootPartLocation.Z}
local playerStats = DataStoreService:GetDataStore(AttackValue, IntellectValue, DexterityValue, DefenseValue, ProfessionValue, LoarxionValue, Location, scope)
print("OK")