In short, I have a furniture system where the cframe of the object in the house is saved, however I want it to be able to change depending on which house it’s in, since I dont want furniture spawning in another random player’s house. Right now, I have
and obviously that wouldn’t work if they had a different house than the starting one, so how would I change it so that it accounts for the new house’s position?
I tried searching here for similar issues, but didn’t find anything
Whilst you’re saving the CFrame of the object, be sure to make it relative via finding the inverse of the house’s base. Egomoose did this rather well in his placement system.
--Example Code (for saving the position)
local position = plrHouse.Base.CFrame:inverse() * Object:GetPrimaryPartCFrame()
--Example Code (for loading)
local components = {}
for num in string.gmatch(cf, "[^%s,]+") do
components[#components+1] = tonumber(num)
end
Object:SetPrimaryPartCFrame(plrHouse.Base.CFrame * CFrame.new(unpack(coms)))
local HouseCenterPart = House.Center
local FurnitureObject = Object
-- Saving The Position
local SavedPosition = HouseCeterPart.Position - FurnitureObject.Position
-- Loading The Position
FurnitureObject.Position = HouseCenterPart.Position + SavedPosition