Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can I not create this CFrame from a string?

Asked by
epoke466 100
2 years ago

I am trying to create a CFrame from a datastore. Sort of....

for key, value in pairs(playerFurnature) do
    local createdItem = game.ReplicatedStorage.Furniture:WaitForChild(key):Clone()
    createdItem.Parent = furnatureModel
    createdItem.CFrame = CFrame.new(value)
end

Using print, I figured out that "value" was a string. (I wrote the code a year ago)

Value also takes the form of: 1000.7243, 19.2989445, -22.6476097, -0.0254777968, 0.0993372351, 0.994727612, -2.32830644e-10, 0.995050609, -0.0993694887, -0.999675393, -0.0025317159, -0.0253516976

Whenever I run the code, I get an error that is something like Expected "Vector3", Got "String".

1 answer

Log in to vote
0
Answered by
Miniller 562 Moderation Voter
2 years ago
Edited 2 years ago

Found this on the Roblox Devforum after a quick search. use a function like

function stringtocf(str)
 return CFrame.new(table.unpack(str:gsub(" ",""):split(",")))
end
0
OMG thank you epoke466 100 — 2y
Ad

Answer this question