Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

House own script not putting the house back up for sale once player leaves?

Asked by 4 years ago

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)

0
this is why you use print()'s so you can see where the code stops DeceptiveCaster 3761 — 4y
0
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. Neon_isHere 100 — 4y
0
No its just the door, Its just making it so only that player can open and close it. Axemurderer27 -3 — 4y

Answer this question