How to store CFrame values into an DataStore?

Hi, I’ve tried to make an thing that will spawn you on the location where you left at the last time via DataStoreService, but DataStore can’t store CFrame values (it’s supporting only UTF-8). Help me.

Store it as a string, you can serialize and deserialize it

local function Serialize(Cf)
  local pos, rot = Cf.Position, Cf.Rotation
  local str = ""..pos.x.."/"..pos.y.."/"..pos.z.."/"..rot.x.."/"..rot.y.."/"..rot.z
  return str
end

local function Deserialize(str)
  local tb = string.split(str, "/")
  local cf = CFrame.new(tb[1], tb[2], tb[3], tb[4]. tb[5], tb[6])
  return cf
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.