Hello. I am trying to make this script work:
local tributegui = game:GetService("ServerStorage"):FindFirstChild("DistrictGUI")
local workspace = game:GetService("Workspace")
script.Parent.Touched:Connect(function(ez)
local player = game:GetService("Players"):GetPlayerFromCharacter(ez.Parent)
local body = workspace:FindFirstChild(ez.Parent.Name)
local checks = player.DistrictChecks
if checks.hasguiequipped.Value == false then
if player then
local tgui = tributegui:Clone()
tgui.TextLabel.TextColor3 = Color3.fromRGB(213, 213, 16)
tgui.Parent = game.Workspace:WaitForChild(player.Name).Head
checks.hasguiequipped.Value = true
checks.D1.Value = true
end
else
if checks.D1.Value == false then
body.Head.DistrictGUI:Destroy()
if player then
local tgui = tributegui:Clone()
tgui.TextLabel.TextColor3 = Color3.fromRGB(213, 213, 16)
tgui.Parent = game.Workspace:WaitForChild(player.Name).Head
checks.hasguiequipped.Value = true
checks.D1.Value = true
checks.D2.Value = false
checks.D3.Value = false
checks.D4.Value = false
checks.D5.Value = false
checks.D6.Value = false
checks.D7.Value = false
checks.D8.Value = false
checks.D9.Value = false
checks.D10.Value = false
checks.D11.Value = false
checks.D12.Value = false
end
end
end
end)
However, this keeps showing up:

DistrictChecks is a folder inside the player.

Player is nil. Something that was not a direct child of a character touched the part. Check if player is nil before continuing with the code.
What does it mean if a player is nil and how do I check that?
This script was working about a month ago, but it for some reason isn’t now. I tried checking if the player is nil, but I couldn’t figure out a way to use that method. Here is my current script:
local tributegui = game:GetService("ServerStorage"):FindFirstChild("DistrictGUI")
local workspace = game:GetService("Workspace")
script.Parent.Touched:Connect(function(ez)
local ggplayer = game:GetService("Players"):GetPlayerFromCharacter(ez.Parent)
local body = workspace:FindFirstChild(ez.Parent.Name)
local checks = game:GetService("Players"):WaitForChild(ez.Parent.Name).DistrictChecks
if checks.hasguiequipped.Value == false then
if ggplayer then
local tgui = tributegui:Clone()
tgui.TextLabel.TextColor3 = Color3.fromRGB(213, 213, 16)
tgui.Parent = game.Workspace:WaitForChild(ggplayer.Name).Head
checks.hasguiequipped.Value = true
checks.D1.Value = true
end
else
if checks.D1.Value == false then
body.Head.DistrictGUI:Destroy()
if ggplayer then
local tgui = tributegui:Clone()
tgui.TextLabel.TextColor3 = Color3.fromRGB(213, 213, 16)
tgui.Parent = game.Workspace:WaitForChild(ggplayer.Name).Head
checks.hasguiequipped.Value = true
checks.D1.Value = true
checks.D2.Value = false
checks.D3.Value = false
checks.D4.Value = false
checks.D5.Value = false
checks.D6.Value = false
checks.D7.Value = false
checks.D8.Value = false
checks.D9.Value = false
checks.D10.Value = false
checks.D11.Value = false
checks.D12.Value = false
end
end
end
end)
It is saying this in the output: