"Attempt to connect failed: Passed value is not a function"

I can’t seem to find where this error is help would be appreciated

 function checkGroupRank(target, groupId, groupId2, minGroupRank, minGroupRank2)
	if groupId then
		if groupId2 then
			local isIn1 = target:IsInGroup(groupId)
			local isIn2 = target:IsInGroup(groupId2)
			
			if isIn2 and isIn1 then
				local groupRank = target:GetRankInGroup(groupId)
				local groupRank2 = target:GetRankInGroup(groupId2)
				return isIn2, isIn2, groupRank, groupRank2
			elseif isIn1 then
				local groupRank = target:GetRankInGroup(groupId)
				return isIn1, groupRank
			elseif isIn2 then
				local groupRank2 = target:GetRankInGroup(groupId2)
				return isIn2, groupRank2
			end
		else
			local isIn1 = target:IsInGroup(groupId)
			if isIn1 == true then
				local groupRank = target:GetRankInGroup(groupId)
				if minGroupRank ~= nil then
					if groupRank >= minGroupRank then
						return isIn1, groupRank
					end
				else
					print("No minGroupRank")
				end
			end
		end
	end
end

game.Players.PlayerAdded:Connect(function(player)
	
	local isIn, IsIn2 = checkGroupRank(player, 10363985)
	if isIn and IsIn2 and groupRank and groupRank2 then
		-- In both group and above above minimun rank
		print(isIn, IsIn2)
	elseif isIn or IsIn2 ~= nil then
		if isIn ~= nil then
			if groupRank ~= nil then
				print(isIn, groupRank)
			end
		elseif IsIn2 ~= nil then
			print(IsIn2, groupRank2)
		end
		
	end
end)

function searchForInName(object)
	local objectName = object.Name
	
	print(objectName)
	
	if string.find(objectName, "Blast") then
		return "Blast"
	elseif string.find(objectName, "Slide") then
		return "Slide"
	elseif string.find(objectName, "Swing") then
		return "Swing"
	elseif string.find(objectName, "DepsSlide") then
		return "DepsSlide"
	end
end

function getDoor(doorType)
	if doorType == "Blast" then
		local Door = script.Parent:FindFirstChild("Door")
		return Door
	elseif doorType == "Slide" then
		local Door1 = script.Parent:FindFirstChild("Gate1")
		local Door2 = script.Parent:FindFirstChild("Gate2")
		return Door1, Door2
	elseif doorType == "Swing" then
		local Door1 = script.Parent:FindFirstChild("Gate1")
		local Door2 = script.Parent:FindFirstChild("Gate2")
		return Door1, Door2
	elseif doorType == "DepsSlide" then
		local Door1 = script.Parent:FindFirstChild("Gate1")
		local Door2 = script.Parent:FindFirstChild("Gate2")
		return Door1, Door2
	end
end

function isNil(object)
	if object ~= nil then
		return false
	else
		return true
	end
end
function TweenDoor(doorType, targetedDoor, tweenInfo, targetedDoor2)
	print("Worked!")
	if doorType == "Blast" then
		local blastTween = TweenService:Create(targetedDoor, tweenInfo, {Position = targetedDoor.Position + Vector3.new(0, targetedDoor.Size.Y, 0)})
		
		blastTween:Play()
	end
end

function onTouched(hit, doorType, Door, Door2)
	local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
	if hum then
		local character = hum.Parent
		if character then
			local player = Players:GetPlayerFromCharacter(character)
			print(player)
			
			if groupId and groupId2 ~= nil then
				local isIn, IsIn2, groupRankRes, groupRankRes2 = checkGroupRank(player, groupId, groupId2)
				
				if isIn then
					if groupRankRes and groupRankRes2 then
						if groupRankRes >= groupRank and groupRankRes2 >= groupRank2 then
							local isNil = isNil(Door2)
							
							if isNil == false then
								TweenDoor(doorType, Door, nil, Door2)
							else
								TweenDoor(doorType, Door, nil)
							end
						end
					end
				end
			elseif groupId ~= nil then
				local isIn, groupRankRes = checkGroupRank(player, groupId)
				
				if isIn then
					if groupRankRes ~= nil and groupRankRes >= groupRank then
						local isNil = isNil(Door2)

						if isNil == false then
							TweenDoor(doorType, Door, nil, Door2)
						else
							TweenDoor(doorType,Door, nil)
						end
					end
				end
			elseif groupId2 ~= nil then
				local isIn, groupRankRes = checkGroupRank(player, groupId2)
				
				if isIn then
					if groupRankRes ~= nil and groupRankRes >= groupRank2 then
						local isNil = isNil(Door2)

						if isNil == false then
							TweenDoor(doorType, Door, nil, Door2)
						else
							TweenDoor(doorType, Door, nil)
						end
					end
				end
			end
			
		end
	end
end

-- Actual functionality --

TouchPart.Touched:Connect(function(hit)
	local doorType = searchForInName(script.Parent)
	local Door, Door2 = getDoor(doorType)
	
	if Door and Door2 ~= nil then
		onTouched(hit, doorType, Door, Door2)
	else
		onTouched(hit, doorType, Door)
	end	
end)
1 Like

What’s the line the error happens on?

1 Like

Thats the issue, it doesn’t specify this is all it says