local Players = game:GetService("Players")
export type Character = Model & {["Humanoid"]: Humanoid, ["HumanoidRootPart"]: Part}
local MoveUtilities : {
["GetClosestFromArray"]: (Character, number, {[number]: Character}) -> Character?,
["GetAllPlayersCharacters"]: () -> {[number]: Character}
} = {["GetClosestFromArray"] = function(
TargetCharacter: Character, Range: number,
ArrayToCheck: {[number]: Character}
) : Character?
if not TargetCharacter or not Range or not ArrayToCheck then
warn("One argument or more arguments are nil! Ending this function.")
return nil
end
local closestCharacter: Character?
for _,char: Character in ArrayToCheck do
local distance = (TargetCharacter.PrimaryPart.Position - char.PrimaryPart.Position).Magnitude
if distance < Range then
Range = distance
closestCharacter = char
end
end
return closestCharacter
end,
["GetAllPlayersCharacters"] = function() : {[number]: Character}
local characterlist = {}
for _,player in Players:GetPlayers() do
local character = player.Character :: Character
if character then
table.insert(characterlist, character)
end
end
return characterlist
end,
}
return MoveUtilities
the script above gives me two warnings:

this line in the script is causing it
local distance = (TargetCharacter.PrimaryPart.Position - char.PrimaryPart.Position).Magnitude
i dont know how to fix this, ive already tried the union type example | nil, example? but seems to have no difference
im using the Strict LuauTypeCheckMode