i'm making a claim for a tycoon game and i'm getting this error for the claim. the script is still doing what i want it to just it's still giving the error
"Workspace.Claim.GateControl:8: attempt to index a nil value"
this is the script that i have
local BValue = script.Parent.BValue
local Owner = script.Parent.Owner
local BillBoard = script.Parent.BillBoard.SurfaceGui.TextLabel
script.Parent.Head.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local playerName = hit.Parent.Name
local Owning = game.Players:FindFirstChild(playerName).Owning
if player ~= nil then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
if BValue.Value == false then
if Owning.Value == false then
Owner.Value = playerName
BillBoard.Text = playerName
BValue.Value = true
Owning.Value = true
script.Parent.Colour.BrickColor =
BrickColor.Green()
end
end
end
end
end
end)

3 comments
Mother of god.
So much nesting. You can also use "and' and "elseif" op.
and ":Connect"