Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Datastore sees a CFrame value as an object?

local DataStore = game:GetService("DataStoreService")

game.Players.PlayerAdded:connect(function(plr)
	local player = plr
	local Saves = player:WaitForChild("Saves")
	local savesAmount = Saves:WaitForChild("SavesAmount")
	local num = 0
	local SavesAMBackup = savesAmount.Value
	
	wait(2)
	
	if savesAmount.Value > 0 then
 		repeat
			local keyStore = DataStore:GetDataStore("keyStore "..num)
			local CFrameData = DataStore:GetDataStore(tostring("CFrameDataStore "..num))
			if keyStore ~= nil then
				local key = keyStore:GetAsync(player.UserId) or false
				
			
				wait()
				num = num + 1
				SavesAMBackup = SavesAMBackup - 1
				
				local folder = Instance.new("Folder")
				folder.Name = num
				folder.Parent = player.Saves
							
				local keyFolder = Instance.new("BoolValue")
				keyFolder.Name = "key"
				keyFolder.Value = key
				keyFolder.Parent = folder
				
				local PlayerPosition = Instance.new("CFrameValue")
				PlayerPosition.Name = "PlayerCFrame"
				PlayerPosition.Value = CFrameData
				PlayerPosition.Parent = folder
			else
				print("datastore nil")
			end
		until SavesAMBackup <= 0
	
	else
		warn("no saves")
	end
	
end)

error; Workspace.DataStore.FolderSave:35: bad argument #3 to 'Value' (CFrame expected, got Object) Very weird because CFrameData is a CFrame... I tried adding value after but that doesn't work either..K.

1 answer

I'm guessing that the cframe was stored in 2 ways: As a table, or in a table. What the script is saying is that the value your trying to add is not a cframe, but its an object instead. Try using:

print(CFrameData)

If it outputs something like table #rjwajwf, then change line 35 to:

PlayerPosition.Value = CFrameData[1]

I hope I could help, if not, let me know.

This discussion is preserved as it was. New answers, comments, and votes are closed.