I am trying to make a house owning script. But a error shows up when I try.
Error: "18:01:35.064 - Workspace.House1.Door.Script:20: attempt to index field 'Value' (a nil value)"
Script:
local occupied = false local price = 500000 script.Parent.ClickDetector.MouseClick:connect(function(player) repeat wait() until player.Character if player:WaitForChild("HouseObject").Value == nil then if occupied == false then if game:GetService("ServerStorage"):WaitForChild("Data"):WaitForChild(player.Name.."Cash").Value >= price then script.Parent.PlayerObject.Value = player player:WaitForChild("HouseObject").Value = script.Parent.Parent occupied = true game:GetService("ServerStorage"):WaitForChild("Cash").Value = game:GetService("ServerStorage"):WaitForChild("Cash").Value -price print(player.Name.." bought a house.") end end end wait(.1) if player.Name == script.Parent.PlayerObject.Value.Name then script.Parent.CanCollide = false wait(3) script.Parent.CanCollide = true else script.Parent.CanCollide = true end end) game.Players.PlayerRemoving:connect(function(player) script.Parent.PlayerObject.Value = nil player:WaitForChild("HouseObject").Value = nil occupied = false end)