Plot ownership erroring

I’m making a tycoon and am currently working on the plot ownership part yet it keep erroring.
Here’s the script:

local Owner = script.Parent.Parent.Owner
local Owned = script.Parent.Parent.Owned
local Plot = script.Parent.Parent.Parent
local TycoonDoor1 = script.Parent
local debounce = false
script.Parent.Touched:Connect(function(hit)
	local plr = game.Players:FindFirstChild(hit.Parent.Name)
	if plr.OwnsAPlot.Value == false then
		if debounce == false then
			if hit.Parent:FindFirstChild("Humanoid")then
				if Owned.Value == false then
					local label = script.Parent.Tycoon_OwnerName.Tycoon_OwnerNameLabel
					label.Text = plr.Name.."'s Tycoon"
					Owner.Value = plr.Name
					Owned.Value = true
					print(Plot.Name.." was claimed by "..plr.Name..".")
					TycoonDoor1.CanCollide = false
					Plot.Sign.TextDisplay.SurfaceGui.TextLabel.Text = plr.Name.."'s Tycoon"
					plr.OwnsAPlot.Value = true
				else
					print("Plot is already owned!")
				end
			end
			debounce = true
			wait(0.5)
			debounce = false
		end
	end
end)

heres a screenshot that shows the script and “OwnsAPlot” in the explorer inside the player:

the error message says it all, there is no “OwnsAPlot” object inside of your player.

make sure that exists first

either that or FindFirstChild is returning nil, which is likely the case

Look at the screenshot first… Or do you mean check within the script if player:FindFirstChild(“OwnsAPlot”) then

Make sure the player exists so it doesn’t error out of no where, since sometimes the part might touch a object which isn’t a character.

1 Like

yeah i noticed afterwards now that it’s probably him trying to find an accessory

if hit.Parent:FindFirstChild(“Humanoid”)then

1 Like

Look at this though. Weird eh?

Do that at the beginning, not after checking the non-existence value.
@detourious’s solution would also work in this case.

or, change line 8 to if plr and plr.OwnsAPlot.Value == false then

simple simple

I think I might have fixed it let me run the game real quick.

SOLUTION:
thanks:
@detourious ,
@flkfv

2 Likes