Why is the function not disconnecting?

Can any one help me understand why runEvent wont disconnect?

--Mainline
plr.PlayerAdded:Connect(function(player) -- when player joins
	player.CharacterAdded:Connect(function(char) -- when the player's character is loaded in
		local humanoidRootPart = char:WaitForChild("HumanoidRootPart") -- wait for HumRP to load in
		local plrHead = char:WaitForChild("Head")
		lookingEvent = dFOV.Touched:Connect(function(hit)
			print("Player can be seen")
			local raycastResult = workspace:Raycast(rayOrigin, plrHead.Position - rayOrigin, raycastParams)
			if raycastResult and raycastResult.Instance then
				if raycastResult.Instance == plrHead then
					runEvent = runServ.Heartbeat:Connect(function()
						dummy:SetPrimaryPartCFrame(CFrame.lookAt(dummyPos, humanoidRootPart.Position * Vector3.new(1,0,1) + dummyPos * Vector3.new(0,1,0)))
						runEvent:Disconnect()
					end)
				end	
			end	
		end)
	end)
end)

This is the part of the code I am talking about

NVM issue fixed

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.