- What do you want to achieve?
- I want to save furniture in my current saving housing system.
So , first you need to know that players can own multiple houses. If they purchase a house, they’ll recieve a Objectvalue with the houseName as the name
game.ReplicatedStorage.Events.HouseShop:WaitForChild("PurchaseHouse").OnServerInvoke = function(player,houseName)
local money = player.leaderstats.Money
local house = game.ServerStorage.House:FindFirstChild(houseName) -- Object of the Item they want to buy
if house then --if the item exist
if game.ServerStorage.PlayerData[player.Name].House:FindFirstChild(houseName) == nil then
if money.Value >= house.Price.Value then
money.Value = money.Value - house.Price.Value -- reduce the money
local itemValue = Instance.new("ObjectValue")
itemValue.Name = houseName
itemValue.Parent = game.ServerStorage.PlayerData[player.Name].House
return true
else
return "NotEnoughMoney"
end
end
end
end
For the saving, I save all the children in the playerfolder (playerData in my example, located in serverstorage ).
pcall(function()
local house = game.ServerStorage.PlayerData[player.Name].House:GetChildren()
local houseTable = {}
for _, v in pairs(house) do
table.insert(houseTable,v.Name)
end
houseDataStore:SetAsync(player.UserId.."-house",houseTable)
end)
If the player joins the game, I simply do this to copy the owned housemodels (via there names) in the playerData folder so he can use the objects to spawn the house later.
if house_data then
for _, house in pairs(house_data) do
if game.ServerStorage.House:FindFirstChild(house) then
local houseClone = game.ServerStorage.House[house]:Clone()
houseClone.Parent = houseData
end
end
else
print("No house data")
end
So thats how I save my cars and houses. Now the question comes on how I would save furniture and the position relativly to the plot the house is placed.
Like I said, Players can own multiple houses so each furniture needs to be for the dedicated house. I don’t want players to place furniture in HouseA and if they spawn HouseB later, the furniture from HouseA is placed in HouseB.
Information you need to know on how I spawn the houses.
I have multiple plots in the world where players can go and interact with. if they interact with they will be displayed a UI.
if they click on a house, they’ll send a event with the houseName and the housePosition ( this is the plotPosition ).
After this I’ll simply run this
game.ReplicatedStorage.Events.HouseShop:WaitForChild("SpawnHouse").OnServerEvent:Connect(function(player,houseName,housePosition)
local house = game.ServerStorage.House:FindFirstChild(houseName):Clone()
house.Name = player.Name.."-House"
house.Parent = game.Workspace
house:SetPrimaryPartCFrame(housePosition.Parent.HouseSpawner.CFrame)
game.Workspace.Building:FindFirstChild(housePosition.Parent.Name).Owner.Value = player.Name
game.Workspace:FindFirstChild(player.Name.."-House").Owner.Value = player.Name
end)
So I believe you know everything you need to know now to help me out figuring out a furniture system.
Basicly I want players to be able to place furniture on there plot down, but it saves relativly to the house they spawned.
Maybe I could combine this with the very good tutorial I saw earlier : Creating A Furniture Placement System
but I don’t really know how because he is using OOP.
If you have any questions I’ll try to answer them!
Any help is appreciated! :))
~J