Attempt to index nil with "Name" error?

Hi.

So I made this script that shows the goal scorer name and adds to their leaderstats. But when i score the goal, I get this error:

image

I am using an object value, and it works in my other scripts, but not in this one for some reason.

Here is the script which is causing the error:

local teams = game:GetService("Teams")


local goal1 = game:GetService("Workspace").Map.goal2
local goal2 = game:GetService("Workspace").Map.goal1
local ball = game:GetService("Workspace"):WaitForChild("TPS")
local rs = game:GetService("ReplicatedStorage")
local me = rs:WaitForChild("Message")

local Kick = false

local Scorer = game:GetService("Workspace"):WaitForChild("TPS"):WaitForChild("Owner").Value

local Scorer_Name = Scorer.Name

local Message = string.upper(Scorer_Name).." SCORED!"



ball.Touched:Connect(function(part)
	if part == goal1 == true and teams.Bayern and teams.GKB == false  then



		me:FireAllClients(Message)
		Scorer.leaderstats.Goals.Value = Scorer.leaderstats.Goals.Value +1

		task.wait(12)
		Kick = false

	elseif part == goal2 == true and teams.Milan and teams.GKM == false then



		me:FireAllClients(Message)
		Scorer.leaderstats.Goals.Value = Scorer.leaderstats.Goals.Value +1

		task.wait(12)
		Kick = false
	end




end)

Are you trying to find the name of a value? Ive never tried that but most likely that wont work, try this:

local Kick = false

local Scorer = game:GetService("Workspace"):WaitForChild("TPS"):WaitForChild("Owner")

local Scorer_Name = Scorer.Value

local Message = string.upper(Scorer_Name).." SCORED!"

And if the value is a variable you should be “less confusing”

Now I get this error.
image

Are your other scripts local?

How are you changing the ObjectValue’s name/value? Remember this doesn’t replicate and since this is a server-sided script, it won’t detect any changes.

yes my other scripts are local. i am using network ownership by the way, which is also serversided

local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("ChangeOwner")
local Event2 = RS:WaitForChild("ChangeValue")

Event.OnServerEvent:connect(function(player, ball)

	local Distance = player.Character.HumanoidRootPart.Position.Magnitude - ball.Position.Magnitude
	if ball.Name ~= "TPS" then return end
	if game:GetService("Workspace"):WaitForChild("TPS" , math.huge).Anchored == true then return end
	if Distance > 10 then return end
	if ball.Owner.Value ~= player then
		ball:SetNetworkOwner(player)

		ball.Owner.Value = player
		ball.ReactDecline.Value = true
		local Bubble = Instance.new("Part")
		Bubble.Shape = "Ball"
		Bubble.Position = ball.Position
		Bubble.Name = "ReactBubble"
		Bubble.CanCollide = false
		Bubble.Anchored = true
		Bubble.Transparency = 0.849
		Bubble.BrickColor = BrickColor.new("Really black")
		Bubble.BrickColor = player.TeamColor
		Bubble.Size = Vector3.new(2,2,2)
		Bubble.Parent = workspace
		wait(0.8)
		ball.ReactDecline.Value = false
		Bubble:Destroy()
	end
end)

Event2.OnServerEvent:connect(function(player, ball)
	if game:GetService("Workspace"):WaitForChild("TPS" , math.huge).Anchored == true then return end
	ball.Ankle.Value = true
	wait(0.5)
	ball.Ankle.Value = false
end)
if game:GetService("Workspace"):WaitForChild("TPS" , math.huge).Anchored == true then return end

UPDATE: The script which is giving the error works sometimes, and doesn’t work sometimes for some reason.