I am so confused

Hello Devs.
So 2 weeks ago I in-countered a glitch in this hitbox that I do not know what to do or how to fix. I kinda find it embarrassed to ask for help but thats besides the point. So the thing is that it detects that the player is down even tho he player didn’t dive and its really messing up with plays and I need this fixed urgently but I don’t know what I’m doin. Please help.

Code:

local char = script.Parent
local canTackle = script:WaitForChild("canTackle")
local repStor = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remote = repStor.Tackle
local messanger = repStor.Messages
local chains = workspace:FindFirstChild("Chains")
local flipped = chains:FindFirstChild("Flipped")
local onGround = false
local ogHit = nil
local sounds = script:WaitForChild("Sounds")
sounds.Parent = char:WaitForChild("Torso")

function push(dir, torso) -- small push function
	for i=1,3 do
		if not torso:FindFirstChild("WindEffect") and not torso:FindFirstChild("BlockWind") then
			local force = Instance.new("BodyVelocity")
			force.Name = "WindEffect"
			force.maxForce = Vector3.new(1e7, 1e7, 1e7)
			force.P = 50
			force.Velocity = (dir * 10)
			force.Parent = torso
			game.Debris:AddItem(force, .25)
		end
	end
end

function block(dir, torso) -- big push function
	for i=1,3 do
		if not torso:FindFirstChild("BlockWind") then
			local force = Instance.new("BodyVelocity")
			force.Name = "BlockWind"
			force.maxForce = Vector3.new(1e7, 1e7, 1e7)
			force.P = 125
			force.velocity =  (dir * 25)
			force.Parent = torso
			game.Debris:AddItem(force, .25)	
		end
	end
end

local tackPushed = false

function tpFalse()
	wait(5)
	tackPushed = false
end

function tackPush(dir, torso) -- small push function
	if not tackPushed then
		tackPushed = true
		for i=1,3 do
			if not torso:FindFirstChild("tackPush")then
				local force = Instance.new("BodyVelocity")
				force.Name = "WindEffect"
				force.maxForce = Vector3.new(1e7, 1e7, 1e7)
				force.P = 50
				force.Velocity = (dir * 10)
				force.Parent = torso
				game.Debris:AddItem(force, .25)	
			end
		end
		spawn(tpFalse)
	end
end

function redLine(ballPos) -- moves line
	chains.Redline.CFrame = CFrame.new(chains.Redline.Position.X, chains.Redline.Position.Y, ballPos)
end

function message(tackledPlr, tackler, event, ballPos, linePos, flipped) --makes message GUI pop up
	local yards = math.floor(((linePos - ballPos)/3.65) + .5)
	messanger:FireAllClients(tackler.Name, tackledPlr.Name, event, yards, flipped)
end

function dropBall(tool)
	local handle = tool:WaitForChild("Handle")
	handle.Name = "Football"
	handle.CanCollide = true
	handle.Parent = workspace
	tool:Destroy()
	handle.Script.Disabled = true
end

function tackle(tackled, tackler, football)
	 -- forward progress & tackle
	local hitPos = football.Handle.Position.Z
	repeat wait() until tackled.Tackle.onGround.Value
	local ballPos = football.Handle.Position.Z
	if flipped.Value then
		if ballPos > hitPos then
			ballPos = hitPos
		end
	else
		if ballPos < hitPos then
			ballPos = hitPos
		end
	end
	if football.Handle.Tucked.Value then
		redLine(ballPos)
		if tackled.Torso.Position.X > 91 or tackled.Torso.Position.X < -89 or tackled.Torso.Position.Z < -218.75 or tackled.Torso.Position.Z > 218.75 then
			message(tackled, tackler, "tackleOOB", ballPos, workspace.Chains.LOS.Line.Position.Z, flipped.Value)
		else
			message(tackled, tackler, "tackle", ballPos, workspace.Chains.LOS.Line.Position.Z, flipped.Value)	
		end
	else
		dropBall(football)
		messanger:FireAllClients(tackled.Name, "", "drop")
	end
end

function OOB()
	if canTackle.Value then
		canTackle.Value = false
		local football = char:WaitForChild("Football")
		local handle = football:WaitForChild("Handle")
		local ballPos = handle.Position.Z
		local yards = math.floor(((workspace.Chains.LOS.Line.Position.Z - ballPos)/3.65) + .5)
		messanger:FireAllClients(char.Name, "", "OOB", yards, flipped.Value)
		redLine(ballPos)
	end
end

function tackOn(canTak1, canTak2)
	wait(.2)
	canTak1.Value = true
	canTak2.Value = true
end

function touched(hit)
	local tackled = nil
	if hit.Parent.Parent.Parent ~= nil and game.Players:FindFirstChild(hit.Parent.Parent.Parent.Name) then
		tackled = hit.Parent.Parent.Parent
	elseif hit.Parent.Parent ~= nil and game.Players:FindFirstChild(hit.Parent.Parent.Name) then
		tackled = hit.Parent.Parent
	elseif hit.Parent ~= nil and game.Players:FindFirstChild(hit.Parent.Name) then
		tackled = hit.Parent
	end
	if tackled~= nil then -- if u hit a Character
		local tackledTackScr = tackled:WaitForChild("Tackle")
		if game.Players:GetPlayerFromCharacter(tackled).TeamColor ~= game.Players:GetPlayerFromCharacter(char).TeamColor then -- if team color isnt same
			if tackled:FindFirstChild("Football") then --if the player being tackled has a ball
				if canTackle.Value and tackledTackScr.canTackle.Value then
					canTackle.Value = false
					sounds.Tackle:Play()
					tackledTackScr.canTackle.Value = false
					if tackled.Football:IsA("Tool") then -- and its a tool
						local football = tackled.Football
						local handle = football:WaitForChild("Handle")
						local tackledCatchScr = tackled:WaitForChild("Catch")
						if tackledTackScr.Block.Value == false and script.Block.Value == false then
							tackPush(char.HumanoidRootPart.CFrame.lookVector, tackled.HumanoidRootPart) -- small push
						end
						tackled.Humanoid.PlatformStand = true
						char.Humanoid.PlatformStand = true
						if handle.Tucked.Value then
							--REGULAR TACKLE
							tackle(tackled, char, football)
						else
							wait(.2)
							if not handle.Tucked.Value then
								if tackledCatchScr.PBUTimer.Value then
									--PBU
									local handle = football:WaitForChild("Handle")
									dropBall(football)
									local thrower
									if Players:FindFirstChild(handle.Thrower.Value) then
										thrower = Players:FindFirstChild(handle.Thrower.Value)
									end
									if thrower.TeamColor == Players:GetPlayerFromCharacter(tackled).TeamColor then
										messanger:FireAllClients(char.Name, tackled.Name, "PBU")
									else
										messanger:FireAllClients(tackled.Name, char.Name, "PBU")
									end
								else
									--FUMBLE
									local handle = football:WaitForChild("Handle")
									dropBall(football)
									messanger:FireAllClients(char.Name, tackled.Name, "fumble") 
									wait(.4)
									tackledTackScr.canTackle.Value = true
									script.canTackle.Value = true
								end
							else
								tackle(tackled, char, football)
							end
						end
					end
				end
			elseif char:FindFirstChild("Football") then
				if canTackle.Value and tackledTackScr.canTackle.Value then
					canTackle.Value = false
					tackledTackScr.canTackle.Value = false
					sounds.Tackle:Play()
					if char.Football:IsA("Tool") then
						local football = char.Football
						local handle = football:WaitForChild("Handle")
						local tackledCatchScr = tackled:WaitForChild("Catch")
						if tackledTackScr.Block.Value == false and script.Block.Value == false then
							tackPush(char.HumanoidRootPart.CFrame.lookVector, tackled.HumanoidRootPart)
						end
						char.Humanoid.PlatformStand = true
						tackled.Humanoid.PlatformStand = true
						if handle.Tucked.Value then
							tackle(char, tackled, football)
						else
							wait(.2)
							if not handle.Tucked.Value then
								if char.Catch.PBUTimer.Value then
									--PBU
									local handle = football:WaitForChild("Handle")
									dropBall(football)
									local thrower
									if Players:FindFirstChild(handle.Thrower.Value) then
										thrower = Players:FindFirstChild(handle.Thrower.Value)
									end
									if thrower.TeamColor == Players:GetPlayerFromCharacter(char).TeamColor then
										messanger:FireAllClients(tackled.Name, char.Name, "PBU")
									else
										messanger:FireAllClients(char.Name, tackled.Name, "PBU")
									end
								else
									--FUMBLE
									local handle = football:WaitForChild("Handle")
									dropBall(football)
									messanger:FireAllClients(tackled.Name, char.Name, "fumble") 
									wait(.4)
									tackledTackScr.canTackle.Value = true
									script.canTackle.Value = true
								end
							else
								tackle(char, tackled, football)
							end
						end
					end
				end
			else
				if script.Block.Value then -- if this character is blocking
					block(char.HumanoidRootPart.CFrame.lookVector, tackled.HumanoidRootPart) -- block push
					sounds.Block:Play()
					if not tackled:FindFirstChild("Helmet") then -- if he doesnt have helmet make him fall
						if not tackled.Humanoid.PlatformStand then
							tackled.Humanoid.PlatformStand = true
							wait(1.7)
							tackled.Humanoid.PlatformStand = false
						end
					end
				else
					push(char.HumanoidRootPart.CFrame.lookVector, tackled.HumanoidRootPart)
				end
			end
		end
	else -- if this char hits the ground
		if char:FindFirstChild("Football") then
			local pbuTimer = char:WaitForChild("Catch").PBUTimer
			local handle = char:WaitForChild("Football").Handle
			if hit.Name == "OOBPart" then
				if not pbuTimer.Value then
					OOB()
				else
					if handle.Tucked.Value then
						OOB()
					end
				end
			else
				if canTackle.Value then
					canTackle.Value = false
					local downPos = handle.Position.Z
					if char.Catch.PBUTimer.Value then
						wait(.2)
						if handle.Tucked.Value then
							redLine(handle.Position.Z)
							message(char, "", "fell", downPos, workspace.Chains.LOS.Line.Position.Z, flipped.Value)
						else
							dropBall(handle.Parent)
							messanger:FireAllClients(char.Name, "", "drop")
						end
					else
						redLine(handle.Position.Z)
						message(char, "","fell", downPos, workspace.Chains.LOS.Line.Position.Z, flipped.Value)
					end
				end
			end
			script.onGround.Value = true -- this sets to true so that when someones tackled it waits till they hit the ground
			wait()
			script.onGround.Value = false
		end
	end
end

function legsTouched(hit)
	if char:FindFirstChild("Football") then
		if hit.Name == "OOBPart" then
			OOB()
		end
	end
end

remote.OnServerEvent:Connect(function(plr, arg1)
	if plr == Players:GetPlayerFromCharacter(char) then
		if arg1 == "Block" then
			script.Block.Value = true
			wait(1.5)
			script.Block.Value = false
		end
	end
end)

canTackle.Changed:Connect(function()
	if not canTackle.Value then
		wait(5)
		canTackle.Value = true
	end
end)

char.HumanoidRootPart.Touched:Connect(touched)
char["Left Leg"].Touched:Connect(legsTouched)
char["Right Leg"].Touched:Connect(legsTouched)

function stand()
	wait(1.7)
	char.Humanoid.PlatformStand = false
end

char.Humanoid.Changed:Connect(function()
	if char.Humanoid.PlatformStand then
		spawn(stand)

end
end)

can you mark the specific code line where it goes wrong? there are too many lines to read that i get very confused

if canTackle.Value then
					canTackle.Value = false
					local downPos = handle.Position.Z
					if char.Catch.PBUTimer.Value then
						wait(.2)
						if handle.Tucked.Value then
							redLine(handle.Position.Z)
							message(char, "", "fell", downPos, workspace.Chains.LOS.Line.Position.Z, flipped.Value)
						else
							dropBall(handle.Parent)
							messanger:FireAllClients(char.Name, "", "drop")
						end
					else
						redLine(handle.Position.Z)
						message(char, "","fell", downPos, workspace.Chains.LOS.Line.Position.Z, flipped.Value)
					end
				end
			end

I think this is it

alright so in the touched function

the function would trigger when the humanoid root part touched something and you’re thinking a player right? but there are no extra if statements to determine if what its touching is a player part or not so since none of the hit.Parent.Parent.Parent blah blah blah thing could check it since it’s not a part of the hit.Parent thingy, it will then proceed to the “else” part and i’m referring to this

i’m not very good but there’s a function near the end that sets the tackle’s value to true 5 seconds after it was set to false which can break a lot of things when incorrectly timed, i’ll give the rest to you to fix this since i dont have much time so good luck!