House refund after leaving a game

I have a game in which players will be able to buy houses.

The whole Bloxburg-like system where the house purchase saves and the player can choose a plot upon rejoining is definitely above my skill-level

Instead, I’d want a system where once a player leaves, the in-game money they paid for a specific house would be refunded into their account so that it wouldn’t be a complete waste and they’d be able to re-purchase it once they return

I know how this would work in theory (game checks what house the player owns, checks how much they paid for said house, pays it into their account once they disconnect) but have no idea how to even begin putting it into practice

Is it even possible? Can you even transfer money into an offline players datastore?

Thank you

Add a value to the house which will be the cost of it and when the player disconnects (before saving cash) you increase their cash by the value of their house.

Add a value for how much the house is worth, then add it while they are leaving.

local dss = game:GetService('DataStoreService')
local moneyStore = dss:GetDataStore('Money')

game.Players.PlayerRemoving:Connect(function(plr)
	moneyStore:IncrementAsync(plr.UserId, House.Value)
end)

something like that should work

1 Like

But if you’re going to be saving the money, why not just save the house they’ve bought as one value, and the money they have as another value?

1 Like