I keep getting this error on my code. I have been trying to fix it for a few days now but i havent been able to figure it out at all.
local function setUpHighlights(thisPlayer, character, role)
local self = TeamController
if role == Enums.IngameTeams.Hunters then
if not character:FindFirstChild("HunterHighlight") then -- ERROR ATTEMPT TO INDEX NIL WITH FINDFIRSTCHILD
if thisPlayer == player then
self.MovementAnimationsController:OverrideAnimations(character, Enums.FlipEnums(Enums.IngameTeams)[role])
self.AbilitiesController:RoleChanged()
self.HighlightController:HighlightAllEnemies()
else
local data = self.DataController:GetData(thisPlayer)
SharedFunctions.ResetAbilities(data)
end
createHighlight(character, Color3.new(0.72549, 0, 0.0117647))
self.SoundController:Play("Switch")
end
else
local highlight = character:FindFirstChild("HunterHighlight")
if highlight then
highlight:Destroy()
if thisPlayer == player then
self.MovementAnimationsController:OverrideAnimations(character)
self.AbilitiesController:RoleChanged()
else
local data = self.DataController:GetData(thisPlayer)
SharedFunctions.ResetAbilities(data)
end
end
end
end
local function setUpPlayerUIs(team, teamList)
local self = TeamController
local template = IngameUI.PlayerFrame
local myTeam, myTeamInfo = self:GetTeam(player)
local gamemode = self.GamemodeController:GetGamemode()
local gamemodeInfo = Gamemodes.NameOrder[gamemode]
task.spawn(function()
for _, thisPlayer: Player in teamList.Players do
if not thisPlayer.Character or not thisPlayer.Parent then continue end
local playerInfo = SharedFunctions.getPlayerAlive(teamList.PlayersAlive, thisPlayer)
if not playerInfo then continue end
self.WeaponController:CheckWeaponState(playerInfo) -- Errors here for character not existing
setUpHighlights(thisPlayer, character, playerInfo and playerInfo.Role) -- Errors here for character not existing
if thisPlayer == player then continue end
local playerTeam, playerTeaminfo = self:GetTeam(thisPlayer)
local clonedTemplate = PlayersHolder:FindFirstChild(tostring(thisPlayer.UserId))
if not clonedTemplate then
clonedTemplate = template:Clone()
clonedTemplate.Name = thisPlayer.UserId
clonedTemplate.PlayerName.Text = thisPlayer.Name
if myTeamInfo == playerTeaminfo then
clonedTemplate.LayoutOrder = 1
else
clonedTemplate.LayoutOrder = 2
end
clonedTemplate.Parent = PlayersHolder
clonedTemplate.PlayerIcon.Image = Players:GetUserThumbnailAsync(thisPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
end
local runnerColour = Color3.new(1, 1, 1)
local hunterColour = Color3.new(0.72549, 0, 0.0117647)
if not playerInfo then
clonedTemplate.LayoutOrder = myTeamInfo == playerTeaminfo and 17 or 18 -- if player died then this
clonedTemplate.PlayerIcon.ImageTransparency = 0.3
clonedTemplate.PlayerIcon.ImageColor3 = Color3.fromRGB(86, 86, 86)
clonedTemplate.PlayerIcon.UIStroke.Transparency = 0.3
clonedTemplate.PlayerIcon.UIStroke.UIGradient.Color = ColorSequence.new(Color3.fromRGB(85, 85, 85))
clonedTemplate.PlayerName.TextTransparency = 0.3
clonedTemplate.PlayerName.TextColor3 = Color3.fromRGB(86, 86, 86)
if gamemodeInfo.MaxTeams then
local teamColour = SharedVariables.TeamColours[team].Colour
clonedTemplate.PlayerIcon.UIStroke.Color = teamColour
else
clonedTemplate.PlayerIcon.UIStroke.Color = runnerColour
end
clonedTemplate.PlayerName.UIStroke.Transparency = 0.3
else
if playerInfo.Role == Enums.IngameTeams.Hunters then
clonedTemplate.PlayerName.TextColor3 = hunterColour
clonedTemplate.PlayerIcon.ImageTransparency = 0
clonedTemplate.PlayerIcon.UIStroke.Transparency = 0
clonedTemplate.PlayerName.TextTransparency = 0
if gamemodeInfo.MaxTeams then
local teamColour = SharedVariables.TeamColours[team].Colour
clonedTemplate.PlayerIcon.UIStroke.Color = teamColour
else
clonedTemplate.PlayerIcon.UIStroke.Color = hunterColour
end
else
clonedTemplate.PlayerName.TextColor3 = runnerColour
clonedTemplate.PlayerIcon.ImageTransparency = 0.4
clonedTemplate.PlayerIcon.UIStroke.Transparency = 0.4
clonedTemplate.PlayerName.TextTransparency = 0.4
if gamemodeInfo.MaxTeams then
local teamColour = SharedVariables.TeamColours[team].Colour
clonedTemplate.PlayerIcon.UIStroke.Color = teamColour
else
clonedTemplate.PlayerIcon.UIStroke.Color = runnerColour
end
end
end
setUpLives(playerInfo, IngameUI.HealthPoint, clonedTemplate.PlayerHealthFrame)
local overheadIcon = thisPlayer.Character:FindFirstChild("OverheadIcon")
if overheadIcon then
setUpLives(playerInfo, IngameUI.OverheadHeart, overheadIcon.Overhead.PlayerHealthFrame)
end
end
end)
end
I put a comment in my code where the error happens. Since its an error that i cant replicate and only really happens in public servers its also really difficult to get the cause. Since im checking to see if the character exists before moving onto the next lines it doesn’t really make sense to me?
Thanks for any help i can get.