I need help saving the angles of a cframe.
right now i’m just using lookvector to set the Cframes rotation but it doesn’t always work
The Problem
robloxapp-20210120-2314023.wmv (489.7 KB)
When its loaded the rotations go weird
probably because I’m using cframe look at
Load Code
local Data = BuildSaveData:GetAsync(Plr.UserId.."-Slot"..tostring(Slot)) if Data and #Data > 0 then print(Plr.Name.."Loaded "..tostring(#Data).." Blocks") for i = 1,#Data do if i > 500 then break end local ActualData = Data[i] local Name = ActualData[1] local Position = ActualData[2] local Rotation = ActualData[3] local RotDirection = Vector3.new(Rotation[1],Rotation[2],Rotation[3]) local Pos = Vector3.new(Position[1],Position[2],Position[3]) + (Vector3.new(0, 10000,Index.Value*200) - Vector3.new(0,36,0)) local Cf = CFrame.new(Pos,Pos+RotDirection) if Name and game.Lighting.Blocks:FindFirstChild(Name) then local Block = GetBlock(Name) Block.Parent = BuildModel Block:SetPrimaryPartCFrame(Cf) RunService.Heartbeat:Wait() elseif Name and Name ~= "Chassis" then if WarnDebug == true then warn(Plr.Name.." Tried to load"..Name) end end if Name and Name == "Chassis" and not BuildModel:FindFirstChild("Chassis") then local Block = game.Lighting.OtherBlocks:FindFirstChild("Chassis"):Clone() Block.Parent = BuildModel Block:SetPrimaryPartCFrame(Cf) Chassis = Block end end end
Save Code
local BuildModel2 if StoredBuildClones:FindFirstChild(Plr.Name) then BuildModel2 = StoredBuildClones:FindFirstChild(Plr.Name) else BuildModel2 = game.Workspace.Builds:FindFirstChild(Plr.Name) or BuildModel end if BuildModel2 then if Debug == true then print("Saving "..Plr.Name.."'s BuildModel"..". Saved "..tostring(#BuildModel2:GetChildren()).." Blocks" ) elseif WarnDebug == true then warn("Failed Saving "..Plr.Name.."'s BuildModel") end end local int2 = 0 repeat wait() int2 = int2 + 1 until BuildModel2 and #BuildModel2:GetChildren() > 1 or int2 > 20 do end local newValue = {} local Blocks = BuildModel2:GetChildren() for i = 1,#Blocks do if i > 500 then break end if game.Lighting.Blocks:FindFirstChild(Blocks[i].Name) or game.Lighting.OtherBlocks:FindFirstChild(Blocks[i].Name) then local Block = Blocks[i].PrimaryPart local MidPos = (Vector3.new(0, 10000,Index.Value*200) - Vector3.new(0,36,0)) local DeltaPosition = (Block.Position-MidPos) local LookVector = Block.CFrame.LookVector table.insert(newValue,{Block.Parent.Name,{DeltaPosition.X,DeltaPosition.Y,DeltaPosition.Z},{LookVector.X,LookVector.Y,LookVector.Z}}) end end local success, err = pcall(function() BuildSaveData:SetAsync(Plr.UserId.."-Slot"..tostring(Slot),newValue) end) if success then if Debug == true then print("Successfully Saved "..Plr.Name.."'s BuildModel"..". With "..tostring(#BuildModel2:GetChildren()).." Blocks") end else if Debug == true then print("Saving WasFailed. Error") warn(err) end end