Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local function Serialize(...: BasePart)
- assert(Players.LocalPlayer)
- local Arguments = { ... }
- local Result = ""
- for Index, Part in Arguments do
- if Index > 1 then
- Result ..= "<seperator>"
- end
- local Origin = CFrame.new(Part.Position)
- * CFrame.fromOrientation(
- math.rad(Part.Orientation.X),
- math.rad(Part.Orientation.Y),
- math.rad(Part.Orientation.Z)
- )
- local Matrices = { Origin:GetComponents() }
- for Index, Point in Matrices do
- if Point < 0 then
- Result ..= "<negative>"
- end
- Result ..= math.abs(Point)
- if typeof(Index) == "number" and Index < #Matrices then
- Result ..= "<end>"
- end
- end
- end
- return Result
- end
- local function Deserialize(Serialized: string)
- local Result = {}
- Serialized = Serialized:gsub("<negative>", "-")
- local Separated = Serialized:split("<seperator>")
- for Index, Value in Separated do
- Result[Index] = CFrame.new(table.unpack(Value:split("<end>")))
- end
- return table.unpack(Result)
- end
- return RunService:IsClient() and Serialize or Deserialize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement