how do i make it so that once you buy a house you cannot buy another? what code would i use and where would i put it??? i need help im such a confused noob thanks so much :P
local house = script.Parent.Parent local houseprice = house:WaitForChild("Price") local currentowner = house:WaitForChild("CurrentOwner") local ClickDetector = script.Parent:WaitForChild("ClickDetector") ClickDetector.MouseClick:Connect(function(player) if player:FindFirstChild("leaderstats") and currentowner.Value == "" then local SC = player.leaderstats:FindFirstChild("SC") -- We know that the player has leaderstats if SC and SC.Value >= houseprice.Value then house.Name = player.Name.."'s House" SC.Value = SC.Value - houseprice.Value currentowner.Value = player.Name end end end)
My best fix to this issue is putting a "BoolValue" in the player. When it's checked it can mean that the player has a house. You can use an "if" statement in your script to check if it's false to allow the player to buy the house. Something like the following from your code:
if player:FindFirstChild("leaderstats") and currentowner.Value == "" and player:FindFirstChild("OwnsHouse").Value ~= true then --Your other code (insert something that changes the value to false "player:FindFirstChild("OwnsHouse").Value = false") end
If you have any questions or issues, please contact me. ;)