Introduction: I'm creating a system that requires me to save a models rotation and retrieve it once the player joins back. I've successfully uploaded, retrieved, and used accordingly all data about the model except it's rotation. I've been working on this for a few days, i'm finally ready to admit that I need help.
Question: How would I get the rotation of a model, store it on DataStore, and retreive it. I wish it was as easy as uploading the whole CFrame values - the position but you can't upload CFrame values to DataStore. I've tried converting the CFrame data to EulerAngles and reconverting to CFrame, it will upload the data but comes back as nil once i try to retreive it, even though it sucessfully uploaded the EulerAngles. I'm likely overthinking this.
Summary: I need to upload the rotation of a model to DataStore. I then need to be able to retrieve the data and set the models new rotation without altering the Model.Position (Vector3).
Side Question: To rotate models I've been setting the PrimaryPart's CFrame which does not automatically change the other parts of the model so i'm running each part through a Transform script I found on another forum, it's a little messy. If you have a good way to rotate a whole model, i will love you forever, in a non-weird way.
Things I've discovered: - In order to upload a table to a DataStore the keys have to be strings. - You can not directly store CFrame values to a DataStore - Model.PrimaryPart.CFrame - Model.PrimaryPart.Position= Returns Rotation Only
First of all, I want you to love me forever. There is this awesome method called SetPrimaryPartCFrame
. It allows you to set the CFrame of a single part within a model, and have all the other parts of the model adjust accordingly.
I don't see how you can be having troubles storing rotation. Just store the numbers of the CFrame? CFrame:components()
I googled the answer, and to my surprise, I answered it!
Note: I've still never had to do this myself, so I can't say that this solution is the absolute best solution, but it is a solution.
These are my outputs for saving and loading. The value of :components() is being successfully transferred. The rotation values do not look correct though... And the models are not rotating. Suggestions? **LOG:** **----------------------------------------------------------** Creating New Model... Action---ListPos--Value Saved: 1 - -337.93368530273 Saved: 2 - 21.104787826538 Saved: 3 - 440.77005004883 Saved: 4 - 1 Saved: 5 - 0 Saved: 6 - 0 Saved: 7 - 0 Saved: 8 - 1 Saved: 9 - 0 Saved: 10 - 0 Saved: 11 - 0 Saved: 12 - 1 Colony Data Saved Sucessfully! GENERATING Colony Item... Loadd: 1 - -337.93368530273 Loadd: 2 - 21.104787826538 Loadd: 3 - 440.77005004883 Loadd: 4 - 1 Loadd: 5 - 0 Loadd: 6 - 0 Loadd: 7 - 0 Loadd: 8 - 1 Loadd: 9 - 0 Loadd: 10 - 0 Loadd: 11 - 0 Loadd: 12 - 1 **----------------------------------------------------------**