I am using a datastore to save an ObjectValue. However, when I try to it says:
15:13:04.266 - ServerScriptService.Scripts.DataStore:20: bad argument #3 to 'Value' (Object expected, got number)
What am I doing wrong?
local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("StatsDataStore")
game.Players.PlayerAdded:Connect(function(player)
local PlayerStats = Instance.new("Folder", player)
PlayerStats.Name = "PlayerStats"
local Points = Instance.new("IntValue", PlayerStats)
Points.Name = "Points"
Points.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, Points.Value)
local SpawnPoint = Instance.new("ObjectValue", PlayerStats)
SpawnPoint.Name = "SpawnPoint"
SpawnPoint.Value = ds1:GetAsync(player.UserId) or game.Workspace.spawn.Spawn1 --error occurs here
ds1:SetAsync(player.UserId, SpawnPoint.Value)
Points.Changed:Connect(function()
ds1:SetAsync(player.UserId, Points.Value)
print("saved points")
end)
SpawnPoint.Changed:Connect(function()
ds1:SetAsync(player.UserId, SpawnPoint.Value)
end)
end)

1 comment
You cannot store object values in a datastore. Only Strings, numbers, arrays, dictionaries, and booleans, as far as I am aware of.