Attempt to index nil with 'Connect'

  1. What do you want to achieve?
    Textlabel to announce the last player who died.
  2. What is the issue?
    If the lastdied.Value changed which means someone new has died, the textlabel should do a Text Animation.
    In the output it says:
    Players.PLAYERWHODIED.PlayerGui.TopText.TextLabel.Status:11: attempt to index nil with ‘Connect’
  3. What solutions have you tried so far?
    I was looking up the error, but nothing helped me.

The local script located under the TextLabel Announcer:

local Configuration = game.Lighting:FindFirstChild("Server")
local lastdied = Configuration:FindFirstChild("LastDied")
local function AnimationText(Animate)
	for i = 1, #Animate do
		script.Parent.Text = string.sub(Animate, 1, i)
		script.click:Play()
	end
	wait(3)
	script.Parent.Text = ""
end
lastdied.Value.Changed:Connect(function(ChangedValue)
	if lastdied.Value == "" then
	else
		
		AnimationText(Configuration.LastDied.Value.." has died.")
	end
end)


The server script in ServerScriptService:


game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:FindFirstChild("Humanoid").Died:Connect(function(DiedLog)
			game.Lighting.Server.LastDied.Value = plr.Name
		end)
	end)
end)
--This Script works perfectly, it's just the local script that's making errors.

Try removing the value from lastdied.value.changed

Oh, it actually worked. Thank you :slight_smile:

I searched more up and if you would like to check when just the value changes this should work How to detect if a value has changed?