|
| 27 Aug 2015 01:16 PM |
Im trying to save/load CFrame positions, and im doing it like
data:SetAsync("Key", tostring(part.CFrame))
and loading like
part.CFrame = CFrame.new(data:GetAsync("Key"))
but it errors Vector3 expected, got string How can I fix this? |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 01:18 PM |
| Just save the position, and set the cframe to the position saved. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 01:19 PM |
| You'll need to find a way to convert your string BACK into a CFrame. |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 01:24 PM |
| I remember there being a 'String to CFrame' converter in Free Models, you can easily find a good one there. |
|
|
| Report Abuse |
|
|
imnota10
|
  |
| Joined: 25 Dec 2010 |
| Total Posts: 2594 |
|
|
| 27 Aug 2015 01:32 PM |
| The second parameter is variant. Why are you converting it to a string? |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 01:34 PM |
| So I can save it, Datastores cant save CFrame values |
|
|
| Report Abuse |
|
|
FiveCakes
|
  |
| Joined: 15 Feb 2012 |
| Total Posts: 5604 |
|
|
| 27 Aug 2015 01:35 PM |
wiki.roblox.com/index.php?title=Data_store
TIP : http://web.roblox.com/Forum-tip-item?id=135187180 |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 27 Aug 2015 01:36 PM |
Just so you know, even if this did work, you are trying to create a cframe from a cframe
|
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 01:42 PM |
data:SetAsync("Key", {part.CFrame}))
part.CFrame = CFrame.new((data:GetAsync("Key"))[1])
or
data:SetAsync("Key", tostring(part.CFrame)))
part.CFrame = (data:GetAsync("Key")) |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Aug 2015 02:04 PM |
| Did you even try those i sent to you? |
|
|
| Report Abuse |
|
|
| |
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 27 Aug 2015 02:07 PM |
I thought you could use tables
local t = {cf:components()}
data:SetAsync("Key",t)
-----------------
local cf = CFrame.new(unpack(data:GetAsync("Key"))) |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 02:07 PM |
If you're loading a position then just do that
data:SetAsync("Key", part.Position)
part.CFrame = CFrame.new(data:GetAsync("Key")) |
|
|
| Report Abuse |
|
|
FiveCakes
|
  |
| Joined: 15 Feb 2012 |
| Total Posts: 5604 |
|
| |
|
|
| 27 Aug 2015 02:08 PM |
| FiveCakes stop posting pointless posts. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 27 Aug 2015 02:09 PM |
| Or you can JSONEncode/Decode the tables and save/load them as strings |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 02:17 PM |
| No, I need rotations aswell |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 27 Aug 2015 02:20 PM |
| cf:components() returns the position and rotational matrix |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 02:22 PM |
why wont
local c = tostring(part.CFrame)
part.CFrame = CFrame.new(c) work? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 27 Aug 2015 02:24 PM |
tostring() makes a string
CFrame.new(x,y,z,m00,m01,m02,m10,m11,m12,m20,m21,m22)
needs 12 numbers
have u read what i suggested |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 02:28 PM |
Idk how to use it
local C = part.CFrame:components()
part2.CFrame = CFrame.new(C)
Is that how? |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 02:29 PM |
| Test it by yourself then show us the results.. Seriously. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 27 Aug 2015 02:30 PM |
Components returns 12 numbers. You are simply setting C to the first number (x position)
local comp = cf:components()
local blah = CFrame.new(unpack(comp)) |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 02:31 PM |
local cf = workspace.Part.CFrame:components() workspace.Part1.CFrame = CFrame.new(cf)
errors
bad argument #1 to 'new' (Vector3 expected, got number) |
|
|
| Report Abuse |
|
|