I FOUND A FIX: I DO NOT KNOW WHY THE FIX WORKS SO IF YOU ARE WILLING TO SHARE INFO I WOULD LOVE THAT. THIS IS NO LONGER AN EMERGENCY. THE FIX IS SIMPLY FLIPPING THE NUMBERS THAT LIKE TO FLIP CHARGE FOR NO REASON BY MULTIPLYING BY NEGATIVE ONE.
This is a support category for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.
You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
-
What is the issue? Include screenshots / videos if possible!
I am trying to save CFrame information in object space, and read it when the player rejoins the game. The objective is to have a part respawn at a plot relative to a part on the plot, with position and rotation taken into consideration.
The issue is that when I save the CFrame in ObjectSpace using :GetComponents() I do not know how to apply it back to the relative part to get the object in the spot I want it relative to the relative part.
This is the information I am passing to the datastore
–use to object space, to convert and items CFrame to be relative to the object referenced
local actualCFrame = ownedItems[player][i].CFrame
local relativeCFrame = actualCFrame:ToObjectSpace(relativePart.CFrame)
--position relative to relative part
local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = relativeCFrame:GetComponents()
--get dimensions
local sizeX = ownedItems[player][i].Size.X
local sizeY = ownedItems[player][i].Size.Y
local sizeZ = ownedItems[player][i].Size.Z
--information regarding thing saved
table.insert(readTable[player], {
sizeX, --1
sizeY,
sizeZ, --3
x, --4
y,
z, --6
R00, --7
R01,
R02, --9
R10, --10
R11,
R12, --12
R20, --13
R21,
R22 --15
})
This is how I am reading this information
for i=1, table.maxn(readTable), 1 do
--read the table and build the CFrame
local relativeCFrame = CFrame.new(
readTable[i][4], readTable[i][5], readTable[i][6],
readTable[i][7], readTable[i][8], readTable[i][9],
readTable[i][10], readTable[i][11], readTable[i][12],
readTable[i][13], readTable[i][14], readTable[i][15])
--assign CFrame to designated part
local part = Instance.new("Part")
--assign physical characteristics
part.Parent = workspace
part.Anchored = true
part.CFrame = relativeCFrame*relativePart.CFrame
part.Size = Vector3.new(readTable[i][1], readTable[i][2], readTable[i][3])
table.insert(ownedItems[player], part)
end
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I have tried using to world space and to object space to reapply the CFrame, I have had some results (such as my current one listed here, where relativeCFrame is the components of the object space CFrame saved) part.CFrame = relativeCFrame*relativePart.CFrame which only put the object in the right spot EXACTLY HALF of the time. This problem is driving me insane. It is the only barrier keeping me from progressing development of my game. Please help.
the following image is the wrong result, happening half of the time
the following image is the correct result, only happening after relogging when wrong result occurs
also, this is the correct CFrame, when loading the information
-29.0507278, -0.19021976, 6.64500618, -0.999980986, -1.38461673e-05, -0.00616208464, -1.42346835e-05, 1, 6.30055147e-05, 0.00616208371, 6.30920331e-05, -0.999980986
and when that correct CFrame is saved, it saves this, which is the wrong CFrame:
-2.93319607, 0.189872026, 1.43535686, -0.999980986, 1.42346835e-05, 0.00616208371, 1.38461673e-05, 1, -6.30920331e-05, -0.00616208464, -6.30055147e-05, -0.999980986