My purchase house script is working for when someone is trying to buy it, but when they leave the game it still says they own it until a new server.
debounce = false
script.Parent.BuySign.Buy.MouseClick:connect(function(player)
if game.Players:findFirstChild(player.Name) ~= nil and not debounce and game.Players:findFirstChild(player.Name):FindFirstChild("HomeOwner") == nil then
if player.leaderstats.Cash.Value >= 500 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 500
debounce = true
script.Parent.BuySign:Destroy()
script.Parent.Owner.Value = player.Name
local own = Instance.new("IntValue")
own.Name = "HomeOwner"
own.Parent = game.Players:findFirstChild(player.Name)
end
end
end)
game.Players.PlayerRemoving:connect(function(player)
if game.Workspace:FindFirstChild(player.Name.."'s House") then
game.Workspace:FindFirstChild(player.Name.."'s House").Owner.Value = ""
game.Workspace:FindFirstChild(player.Name.."'s House"):FindFirstChild(player.Name.."'s House").Name = "Buy this house!"
end
end)

3 comments
this is why you use print()'s so you can see where the code stops
I'm assuming the house is in a model, are you even changing the name of the model to 'Player's House'? With player obviously being the player's username.
No its just the door, Its just making it so only that player can open and close it.