hey developers, i’ve been working on a datastore which simply saves an objectvalue, but when i try to set the data it just says ‘Instance Expected, got String’.
whats happening
first 2 attempts at running the game, no output, the 3rd attempt it saves the data and the fourth attempt it gives me these errors.
local DSS = game:GetService('DataStoreService')
local invDS = DSS:GetDataStore('InventoryStorage')
game.Players.PlayerAdded:Connect(function(player)
local Taker1 = Instance.new('ObjectValue', game.StarterGui.Inventory:WaitForChild('InventoryStorageS1').SlotOneData)
Taker1.Name = 'TakerS1'
Taker1.Value = game.ServerStorage.CommonTrails.CloudTrail
local data
local success, errormessage = pcall(function()
data = invDS:GetAsync(player.UserId..'-isSlot1Taken-dataStoreValue-1726-4914')
end)
if success then
Taker1.Value = data
else
game.ReplicatedStorage.Remotes.DataFailed:FireClient(player)
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
invDS:SetAsync(player.UserId..'-isSlot1Taken-dataStoreValue-1726-4914', game:GetService('HttpService'):JSONEncode(game.StarterGui.Inventory.InventoryStorageS1.SlotOneData.TakerS1))
end)
if success then
print('Data Saved Successfully!')
else
game.ReplicatedStorage.Remotes.DataFailed:FireClient(player)
warn(errormessage)
end
end)
any solutions would be greatly appreciated
cheers