Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why can I not create this CFrame from a string?

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

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

1 comment

0

OMG thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.