Placement system issues

Hello,
I am trying to have a room building system where players can place furniture.
The system does correctly place furniture, and does save them. However, when loading the furniture, they are not charging in the same room (e.g. If you had room 1, and you get room 5 on the next join, your furniture is loaded in room 1 instead of 5).

Is there a way to get the furniture (which are models) position on a part (the room floor in our case) instead of the world location?

I have the following code to save the datas :

function PlacementServices.SaveData(plr, Room)
	local RoomOwned = Room.Name
	local RoomValue = nil
	local RoomPart = nil
	local DATA = {}
	
	RoomValue = Room

	RoomPart = game.Workspace[RoomOwned].RoomFloor

	for i,v in pairs(RoomPart.Parent.RoomFurniture:GetChildren()) do
		local model = v
		local floor = RoomPart
		local modelCFrame = model:GetPrimaryPartCFrame()
		local floorCFrame = floor.CFrame
		local modelOrientation = model.PrimaryPart.Orientation
		local eulerAngles = CFrame.fromEulerAnglesXYZ(modelOrientation.X, modelOrientation.Y, modelOrientation.Z)
		local modelPosition = modelCFrame.p 
		local floorPosition = floorCFrame.p 
		
		print(modelPosition)

		local distance = (modelPosition - floorPosition).magnitude
		local position = floorPosition + (modelPosition - floorPosition).unit * distance
		print(position)

		table.insert(DATA, {model.Name, position.x, position.y, position.z, eulerAngles.X, eulerAngles.Y, eulerAngles.Z})
		print(DATA)
	end

Thanks…

Learn these What does ToObjectSpace() and ToWorldSpace() do?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.